-
Notifications
You must be signed in to change notification settings - Fork 46
/
plain.test.js
32 lines (28 loc) · 1.01 KB
/
plain.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const test = require('tape');
const db = require('./db');
const dumpster = require('../');
test('plaintext', function (t) {
const dbName = 'plainwiki';
const obj = {
file: './tests/tinywiki-latest-pages-articles.xml',
db: dbName,
plaintext: true,
workers: 1
};
db.drop(dbName, 'pages', () => {
dumpster(obj, () => {
db.firstTen(dbName, (docs) => {
t.equal(docs.length, 7, '7 records');
const doc = docs.find((d) => d._id === 'Hello');
t.ok(doc.plaintext.indexOf('hello this is wikitext') !== -1, 'got plaintext');
const redirect = docs.find((d) => d.title === 'Redirect page');
t.notEqual(undefined, redirect, 'no redirect-page');
t.equal(redirect.redirectTo.page, 'The Beatles', 'has redirect link');
const disambig = docs.find((d) => d.title === 'Disambiguation page');
t.notEqual(undefined, disambig, 'no disambig-page');
t.ok(disambig.sections.length > 1, 'rendering sections');
t.end();
});
});
});
});