-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.js
60 lines (53 loc) · 1.95 KB
/
tests.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
mocha.setup('tdd');
let expect = chai.expect;
const wbURL = 'http://web.archive.org/web/20170101000000/http://example.com';
const nonWBURL = 'http://example.com';
const wbTab = {url: wbURL};
const nonWBTab = {url: nonWBURL};
const testURLs = {
archiveRequest: [
'http://web.archive.org/web/20110901233330/reuters.com',
'web.archive.org/web/20110901233330/reuters.com',
'web.archive.org/web/20000901000000/http://example.com',
'web.archive.org/web/20000901000000/http://example.com?query=thing&another=baz',
'http://web.archive.org/web/20110901231830im_/http://www.google.com/intl/en_ALL/images/srpr/logo1w.png',
],
archiveEscape: [
'example.com',
'example.com/path',
'example.com/path?query=thing',
'http://example.com',
'https://example.com',
],
waybackMachineMetaRequest: [
'https://archive.org/includes/fonts/Iconochive-Regular.woff?-ccsheb',
'http://web.archive.org/static/css/banner-styles.css?v=1492119409.0',
'http://web.archive.org/images/srpr/nav_logo80.png',
],
unclassifiedRequest: [ ], // I can't think of anything that should be unclassified.
}
// Tests for some methods in Measure.js.
suite('Background.js', function() {
setup(function() {});
test('classifyRequest() inside archive', function() {
Object.keys(testURLs).forEach((urlType) => {
let urlSet = testURLs[urlType];
urlSet.forEach((url) => {
let requestType = classifyRequest({'url': url}, wbTab);
expect(requestType, url).to.be.a('string');
expect(requestType, url).to.equal(urlType);
});
});
});
test('classifyRequest() outside archive', function() {
Object.keys(testURLs).forEach((urlType) => {
let urlSet = testURLs[urlType];
urlSet.forEach((url) => {
let requestType = classifyRequest({'url': url}, nonWBTab);
expect(requestType, url).to.be.a('string');
expect(requestType, url).to.equal('notOnArchive');
});
});
});
});
mocha.run();