/
ProvidePlugin.test.js
76 lines (69 loc) · 2.13 KB
/
ProvidePlugin.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
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
'use strict';
const testServer = require('../helpers/test-server');
const config = require('../fixtures/provide-plugin-config/webpack.config');
const runBrowser = require('../helpers/run-browser');
describe.skip('ProvidePlugin', () => {
describe('inline', () => {
beforeAll((done) => {
const options = {
port: 9000,
host: '0.0.0.0',
inline: true,
watchOptions: {
poll: true,
},
};
testServer.startAwaitingCompilation(config, options, done);
});
afterAll(testServer.close);
describe('on browser client', () => {
it('should inject SockJS client implementation', (done) => {
runBrowser().then(({ page, browser }) => {
page.waitForNavigation({ waitUntil: 'load' }).then(() => {
page
.evaluate(() => {
return window.injectedClient === window.expectedClient;
})
.then((isCorrectClient) => {
expect(isCorrectClient).toBeTruthy();
browser.close().then(done);
});
});
page.goto('http://localhost:9000/main');
});
});
});
});
describe('not inline', () => {
beforeAll((done) => {
const options = {
port: 9000,
host: '0.0.0.0',
inline: false,
watchOptions: {
poll: true,
},
};
testServer.startAwaitingCompilation(config, options, done);
});
afterAll(testServer.close);
describe('on browser client', () => {
it('should not inject client implementation', (done) => {
runBrowser().then(({ page, browser }) => {
page.waitForNavigation({ waitUntil: 'load' }).then(() => {
page
.evaluate(() => {
// eslint-disable-next-line no-undefined
return window.injectedClient === undefined;
})
.then((isCorrectClient) => {
expect(isCorrectClient).toBeTruthy();
browser.close().then(done);
});
});
page.goto('http://localhost:9000/main');
});
});
});
});
});