-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test to check if media files are not downloading from hidden el…
…ements
- Loading branch information
1 parent
e350e43
commit 08d56d8
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as mwoffliner from '../../src/mwoffliner.lib.js' | ||
import { execa } from 'execa' | ||
import rimraf from 'rimraf' | ||
import { zimdumpAvailable, zimdump } from '../util.js' | ||
import 'dotenv/config' | ||
import { jest } from '@jest/globals' | ||
|
||
jest.setTimeout(20000) | ||
|
||
describe('treatment test', () => { | ||
const now = new Date() | ||
const testId = `mwo-test-${+now}` | ||
|
||
const articleList = 'Read_my_lips:_no_new_taxes' | ||
const parameters = { | ||
mwUrl: 'https://en.wikipedia.org', | ||
adminEmail: '[email protected]', | ||
articleList, | ||
outputDirectory: testId, | ||
redis: process.env.REDIS, | ||
} | ||
|
||
test('media file from hidden element should not be downloaded', async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
|
||
const outFiles = await mwoffliner.execute(parameters) | ||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
|
||
if (await zimdumpAvailable()) { | ||
await expect(zimdump(`list --url "I/George_Bush_1988_No_New_Taxes.ogg" ${outFiles[0].outFile}`)).rejects.toThrow('Entry not found') | ||
} else { | ||
console.log('Zimdump not installed, skipping test') | ||
} | ||
|
||
rimraf.sync(`./${testId}`) | ||
}) | ||
}) |