-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replacing script.src with empty string if it contains load.php
Added test for getting articles from vikidia.org
- Loading branch information
1 parent
5b65baa
commit 0431b73
Showing
3 changed files
with
45 additions
and
2 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
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
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,43 @@ | ||
import * as mwoffliner from '../../src/mwoffliner.lib.js' | ||
import { execa } from 'execa' | ||
import rimraf from 'rimraf' | ||
import { zimcheckAvailable, zimcheck } from '../util.js' | ||
import 'dotenv/config.js' | ||
import { jest } from '@jest/globals' | ||
|
||
jest.setTimeout(200000) | ||
|
||
describe('vikidia', () => { | ||
const now = new Date() | ||
const testId = `mwo-test-${+now}` | ||
|
||
const parameters = { | ||
mwUrl: 'https://en.vikidia.org', | ||
adminEmail: 'test@kiwix.org', | ||
outputDirectory: testId, | ||
redis: process.env.REDIS, | ||
articleList: 'Alaska', | ||
} | ||
|
||
test('right scrapping from vikidia.org', async () => { | ||
await execa('redis-cli flushall', { shell: true }) | ||
|
||
const outFiles = await mwoffliner.execute(parameters) | ||
|
||
// Created 1 output | ||
expect(outFiles).toHaveLength(1) | ||
|
||
if (await zimcheckAvailable()) { | ||
await expect(zimcheck(outFiles[0].outFile)).resolves.not.toThrowError() | ||
} else { | ||
console.log('Zimcheck not installed, skipping test') | ||
} | ||
|
||
// TODO: clear test dir | ||
rimraf.sync(`./${testId}`) | ||
|
||
const redisScan = await execa('redis-cli --scan', { shell: true }) | ||
// Redis has been cleared | ||
expect(redisScan.stdout).toEqual('') | ||
}) | ||
}) |