|
19 | 19 |
|
20 | 20 | const OfflineGather = require('../../../gather/gatherers/offline'); |
21 | 21 | const assert = require('assert'); |
| 22 | +const tracingData = require('../../fixtures/traces/network-records.json'); |
22 | 23 | let offlineGather; |
23 | 24 |
|
24 | | -describe('HTTP Redirect gatherer', () => { |
| 25 | +describe('Offline gatherer', () => { |
25 | 26 | // Reset the Gatherer before each test. |
26 | 27 | beforeEach(() => { |
27 | 28 | offlineGather = new OfflineGather(); |
28 | 29 | }); |
29 | 30 |
|
30 | | - it('returns an artifact', () => { |
31 | | - return offlineGather.afterPass({ |
32 | | - driver: { |
33 | | - sendCommand() { |
34 | | - return Promise.resolve(); |
35 | | - }, |
36 | | - evaluateAsync() { |
37 | | - return Promise.resolve({offlineResponseCode: 200}); |
38 | | - } |
39 | | - } |
40 | | - }).then(_ => { |
41 | | - assert.deepEqual(offlineGather.artifact, {offlineResponseCode: 200}); |
42 | | - }); |
| 31 | + it('returns an artifact set to -1 when offline loading fails', () => { |
| 32 | + offlineGather.afterPass({url: 'https://do-not-match.com'}, tracingData); |
| 33 | + assert.deepEqual(offlineGather.artifact, -1); |
43 | 34 | }); |
44 | 35 |
|
45 | | - it('handles driver sendCommand() failure', () => { |
46 | | - return offlineGather.afterPass({ |
47 | | - driver: { |
48 | | - sendCommand() { |
49 | | - return Promise.reject('such a fail'); |
50 | | - } |
51 | | - } |
52 | | - }).then(_ => { |
53 | | - assert(false); |
54 | | - }).catch(_ => { |
55 | | - assert.deepEqual(offlineGather.artifact, {offlineResponseCode: -1}); |
56 | | - }); |
| 36 | + it('returns an artifact set to 200 when offline loading succeeds', () => { |
| 37 | + offlineGather.afterPass({url: 'https://ifixit-pwa.appspot.com'}, tracingData); |
| 38 | + assert.deepEqual(offlineGather.artifact, 200); |
57 | 39 | }); |
58 | 40 | }); |
0 commit comments