-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify.js
60 lines (54 loc) · 2.32 KB
/
verify.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
const { readResources, defaultLists, regionalLists } = require('.')
const tap = require('tap')
const { Engine, FilterFormat, FilterSet } = require('adblock-rs')
tap.test('resources are parsed OK by adblock-rust', childTest => {
const resources = readResources()
const filterSet = new FilterSet()
const engine = new Engine(filterSet)
resources.forEach(resource => {
try {
engine.addResource(resource)
} catch(e) {
console.error("Encountered an error when attempting to add this resource:", resource)
throw e
}
})
childTest.end()
})
tap.test('default filter lists are correctly formatted', childTest => {
defaultLists.forEach(list => {
tap.ok(list.uuid !== undefined && typeof list.uuid === 'string')
tap.ok(list.url !== undefined && typeof list.url === 'string')
tap.ok(list.title !== undefined && typeof list.title === 'string')
let supportedFormat = false
for (const format in FilterFormat) {
if (list.format === FilterFormat[format]) {
supportedFormat = true
}
}
tap.ok(supportedFormat)
tap.ok(list.support_url !== undefined && typeof list.support_url === 'string')
})
childTest.end()
})
tap.test('regional filter lists are parsed OK by adblock-rust', childTest => {
regionalLists.forEach(list => {
tap.ok(list.uuid !== undefined && typeof list.uuid === 'string')
tap.ok(list.url !== undefined && typeof list.url === 'string')
tap.ok(list.title !== undefined && typeof list.title === 'string')
let supportedFormat = false
for (const format in FilterFormat) {
if (list.format === FilterFormat[format]) {
supportedFormat = true
}
}
tap.ok(supportedFormat)
tap.ok(list.langs !== undefined && Array.isArray(list.langs))
list.langs.forEach(lang => tap.ok(typeof lang === 'string'))
tap.ok(list.support_url !== undefined && typeof list.support_url === 'string')
tap.ok(list.component_id !== undefined && typeof list.component_id === 'string')
tap.ok(list.base64_public_key !== undefined && typeof list.base64_public_key === 'string')
tap.ok(list.desc !== undefined && typeof list.desc === 'string')
})
childTest.end()
})