-
Notifications
You must be signed in to change notification settings - Fork 4
/
TextExtractor.test.js
46 lines (35 loc) · 1.27 KB
/
TextExtractor.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const assert = require('assert');
const {bot, TextExtractor} = require('./botbase');
const {preprocessDraftForExtract} = require('./reports/commons')
describe('TextExtractor', () => {
before(function() {
return bot.getSiteInfo();
});
it('removes templates on new lines', function() {
let text = `{{use dmy dates}}
{{infobox person
| name = Arthur A. Kempod
| born = {{birth date and age|1988|04|09}}
| occupation = {{flatlist|Weaver
*Tailer
*Knitter
}}
}}
Arthur was an fine tailor.
`;
assert.strictEqual(TextExtractor.removeTemplatesOnNewlines(text), '\n\nArthur was an fine tailor.\n');
});
it('removes templates', () => {
let text = `lorem {{IPA-en|234}} ipsum.{{sfn|pwer= werf &3r |3=E |er}} Ipsum {{sfne}}. Lorem{{r|er}}.{{sfn|Löchte|2008|p=[https://books.google.com/books?id=jEHzS8W1oY8C&pg=PA107 107]}}`;
assert.strictEqual(
TextExtractor.getExtract(text),
'lorem ipsum. Ipsum {{sfne}}. Lorem.'
);
});
it('runs preprocessHook', function () {
let text = `[[User:Example]] 21:09, 30 May 2020 (UTC){{AfC submission|t||ts=20200530210953|u=Harshit567|ns=118|demo=}}
==References==`;
let extract = TextExtractor.getExtract(text, 250, 500, preprocessDraftForExtract);
assert.strictEqual(extract, `[[User:Example]] 21:09, 30 May 2020 (UTC)`);
});
});