-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathwpt-app.html
103 lines (89 loc) · 2.96 KB
/
wpt-app.html
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script src="../../node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script>
<script src="../../node_modules/wct-browser-legacy/browser.js"></script>
<script type="module" src="../../views/wpt-app.js"></script>
</head>
<body>
<test-fixture id="wpt-app-fixture">
<template>
<wpt-app></wpt-app>
</template>
</test-fixture>
<script type="module">
import '../../views/wpt-app.js';
import { TEST_RUNS_DATA } from './util/helpers.js';
suiteSetup(() => {
window.fetch = (url) => {
const href = url instanceof URL ? url.href : 'unknown';
assert.fail('actual', 'expected', `uncaptured fetch: ${href}`);
};
});
suite('<wpt-app>', () => {
let sandbox;
setup(() => {
sandbox = sinon.sandbox.create();
// Spoof an empty result for APIs used in this suite.
const captured = new RegExp('/api/(shas|versions|interop)');
sandbox.stub(window, 'fetch', url => {
if (url === undefined) {
throw 'url is undefined';
}
if (captured.test(url.pathname)) {
return Promise.resolve(new Response('[]'));
}
throw url.pathname;
});
});
teardown(() => {
sandbox.restore();
});
suite('WPTApp.prototype.*', () => {
let appFixture;
setup(() => {
appFixture = fixture('wpt-app-fixture');
appFixture.path = '/';
appFixture.testRuns = Array.from(TEST_RUNS_DATA);
});
suite('computeResultsTotalsRangeMessage', () => {
test('absent/zero', () => {
appFixture.searchResults = null;
expect(appFixture.resultsTotalsRangeMessage).to.not.contain('0 tests');
appFixture.searchResults = [];
expect(appFixture.resultsTotalsRangeMessage).to.not.contain('0 tests');
appFixture.page = 'results';
expect(appFixture.resultsTotalsRangeMessage).to.not.contain('0 tests');
});
test('single', () => {
appFixture.searchResults = [
{test: '/abc.html', legacy_status: [{total: 1}, {total: 1}]},
];
appFixture.page = 'results';
expect(appFixture.resultsTotalsRangeMessage).to.not.contain('1 tests');
expect(appFixture.resultsTotalsRangeMessage).to.not.contain('1 subtests');
});
test('some sum', () => {
appFixture.searchResults = [
{test: '/abc.html', legacy_status: [{total: 1}, {total: 5}]},
{test: '/def.html', legacy_status: [{total: 2}, {total: 1}]},
];
appFixture.page = 'results';
expect(appFixture.resultsTotalsRangeMessage).to.contain('2 tests');
expect(appFixture.resultsTotalsRangeMessage).to.contain('7 subtests');
});
});
suite('computePathIsRootDir ', () => {
test('root dir', () => {
assert.isTrue(appFixture.computePathIsRootDir(appFixture.path));
});
test('not root dir', () => {
assert.isFalse(appFixture.computePathIsRootDir('/a/b'));
});
});
});
});
</script>
</body>
</html>