Skip to content

Commit

Permalink
Fix codefactor issue in saveArticles test
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimKovalenkoSNF committed Oct 25, 2023
1 parent f02cf1d commit e9812d3
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions test/unit/saveArticles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,18 +317,25 @@ describe('saveArticles', () => {
const { downloader } = await setupScrapeClasses() // en wikipedia

const _moduleDependencies = await downloader.getModuleDependencies('Potato')
// next variables declared to avoid "variable is not defined" errors

let RLCONF: any
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let RLSTATE: any
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let RLPAGEMODULES: any
// eslint-disable-next-line @typescript-eslint/no-unused-vars

const document: any = { documentElement: { className: '' }, cookie: '' }

// eslint-disable-next-line no-eval
eval(_moduleDependencies.jsConfigVars)
expect(RLCONF).toMatchObject({
// Create a new function that sets the values
const setJsConfigVars = new Function(`
return function(RLCONF, RLSTATE, RLPAGEMODULES, document) {
${_moduleDependencies.jsConfigVars}
return { RLCONF, RLSTATE, RLPAGEMODULES };
};
`)()

// Execute the created function
const { RLCONF: updatedRLCONF } = setJsConfigVars(RLCONF, RLSTATE, RLPAGEMODULES, document)

expect(updatedRLCONF).toMatchObject({
wgPageName: 'Potato',
wgTitle: 'Potato',
wgPageContentLanguage: 'en',
Expand Down

0 comments on commit e9812d3

Please sign in to comment.