Skip to content

Commit 4558b1e

Browse files
authored
chore: fix tests (#1997)
1 parent dfe1a4f commit 4558b1e

10 files changed

+138
-29
lines changed

client-src/clients/BaseClient.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
/* eslint-disable
42
no-unused-vars
53
*/

client-src/clients/SockJSClient.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
/* eslint-disable
42
no-unused-vars
53
*/

client-src/clients/WebsocketClient.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
const BaseClient = require('./BaseClient');
42

53
module.exports = class WebsocketClient extends BaseClient {};
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Server addEntries add hot option 1`] = `
4+
Array [
5+
Array [
6+
"client",
7+
"index.js?http:",
8+
"localhost",
9+
],
10+
Array [
11+
"node_modules",
12+
"webpack",
13+
"hot",
14+
"dev-server.js",
15+
],
16+
Array [
17+
"foo.js",
18+
],
19+
]
20+
`;
21+
22+
exports[`Server addEntries add hot option 2`] = `
23+
Array [
24+
HotModuleReplacementPlugin {
25+
"fullBuildTimeout": 200,
26+
"multiStep": undefined,
27+
"options": Object {},
28+
"requestTimeout": 10000,
29+
},
30+
]
31+
`;
32+
33+
exports[`Server addEntries add hotOnly option 1`] = `
34+
Array [
35+
Array [
36+
"client",
37+
"index.js?http:",
38+
"localhost",
39+
],
40+
Array [
41+
"node_modules",
42+
"webpack",
43+
"hot",
44+
"only-dev-server.js",
45+
],
46+
Array [
47+
"foo.js",
48+
],
49+
]
50+
`;
51+
52+
exports[`Server addEntries add hotOnly option 2`] = `
53+
Array [
54+
HotModuleReplacementPlugin {
55+
"fullBuildTimeout": 200,
56+
"multiStep": undefined,
57+
"options": Object {},
58+
"requestTimeout": 10000,
59+
},
60+
]
61+
`;
62+
63+
exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 1`] = `
64+
Array [
65+
"errors",
66+
"warnings",
67+
"hash",
68+
"assetsByChunkName",
69+
"assets",
70+
"filteredAssets",
71+
]
72+
`;
73+
74+
exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 2`] = `
75+
Array [
76+
"errors",
77+
"warnings",
78+
"hash",
79+
"assetsByChunkName",
80+
"assets",
81+
"filteredAssets",
82+
]
83+
`;
84+
85+
exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 3`] = `
86+
Array [
87+
"errors",
88+
"warnings",
89+
"hash",
90+
"assetsByChunkName",
91+
"assets",
92+
"filteredAssets",
93+
]
94+
`;
95+
96+
exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 4`] = `
97+
Array [
98+
"errors",
99+
"warnings",
100+
"hash",
101+
"assetsByChunkName",
102+
"assets",
103+
"filteredAssets",
104+
]
105+
`;
106+
107+
exports[`Server stats should works with difference stats values (contains 'hash', 'assets', 'warnings' and 'errors') 5`] = `
108+
Array [
109+
"errors",
110+
"warnings",
111+
"hash",
112+
"assetsByChunkName",
113+
"assets",
114+
"filteredAssets",
115+
]
116+
`;

test/client/utils/createSocketUrl.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('createSocketUrl', () => {
2424
const {
2525
default: createSocketUrl,
2626
// eslint-disable-next-line global-require
27-
} = require('../../../../client-src/default/utils/createSocketUrl');
27+
} = require('../../../client-src/default/utils/createSocketUrl');
2828

2929
test(`should return the url when __resourceQuery is ${url}`, () => {
3030
expect(createSocketUrl(url)).toMatchSnapshot();

test/client/utils/getCurrentScriptSource.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const {
44
default: getCurrentScriptSource,
5-
} = require('../../../../client-src/default/utils/getCurrentScriptSource');
5+
} = require('../../../client-src/default/utils/getCurrentScriptSource');
66

77
describe('getCurrentScriptSource', () => {
88
afterEach(() => {

test/client/utils/reloadApp.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ describe('reloadApp', () => {
2525
});
2626

2727
// eslint-disable-next-line global-require
28-
reloadApp = require('../../../../client-src/default/utils/reloadApp')
29-
.default;
28+
reloadApp = require('../../../client-src/default/utils/reloadApp').default;
3029
});
3130

3231
afterEach(() => {

test/client/utils/sendMessage.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const {
66
default: sendMessage,
7-
} = require('../../../../client-src/default/utils/sendMessage');
7+
} = require('../../../client-src/default/utils/sendMessage');
88

99
describe('sendMessage', () => {
1010
afterEach(() => {

test/server/open-option.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'use strict';
22

3-
jest.mock('opn');
3+
jest.mock('open');
44

55
const webpack = require('webpack');
6-
const opn = require('opn');
6+
const open = require('open');
77
const Server = require('../../lib/Server');
88
const config = require('../fixtures/simple-config/webpack.config');
99

10-
opn.mockImplementation(() => {
10+
open.mockImplementation(() => {
1111
return {
1212
catch: jest.fn(),
1313
};
@@ -21,8 +21,8 @@ describe('open option', () => {
2121
});
2222

2323
compiler.hooks.done.tap('webpack-dev-server', () => {
24-
expect(opn.mock.calls[0]).toEqual(['http://localhost:8080/', {}]);
25-
expect(opn.mock.invocationCallOrder[0]).toEqual(1);
24+
expect(open.mock.calls[0]).toEqual(['http://localhost:8080/', {}]);
25+
expect(open.mock.invocationCallOrder[0]).toEqual(1);
2626
server.close(done);
2727
});
2828

test/server/utils/runOpen.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
'use strict';
22

3-
const opn = require('opn');
3+
const open = require('open');
44
const runOpen = require('../../../lib/utils/runOpen');
55

6-
jest.mock('opn');
6+
jest.mock('open');
77

88
describe('runOpen util', () => {
99
afterEach(() => {
10-
opn.mockClear();
10+
open.mockClear();
1111
});
1212

1313
describe('should open browser', () => {
1414
beforeEach(() => {
15-
opn.mockImplementation(() => Promise.resolve());
15+
open.mockImplementation(() => Promise.resolve());
1616
});
1717

1818
it('on specify URL', () => {
1919
return runOpen('https://example.com', {}, console).then(() => {
20-
expect(opn.mock.calls[0]).toEqual(['https://example.com', {}]);
20+
expect(open.mock.calls[0]).toEqual(['https://example.com', {}]);
2121
});
2222
});
2323

@@ -27,7 +27,7 @@ describe('runOpen util', () => {
2727
{ openPage: '/index.html' },
2828
console
2929
).then(() => {
30-
expect(opn.mock.calls[0]).toEqual([
30+
expect(open.mock.calls[0]).toEqual([
3131
'https://example.com/index.html',
3232
{},
3333
]);
@@ -40,7 +40,7 @@ describe('runOpen util', () => {
4040
{ open: 'Google Chrome' },
4141
console
4242
).then(() => {
43-
expect(opn.mock.calls[0]).toEqual([
43+
expect(open.mock.calls[0]).toEqual([
4444
'https://example.com',
4545
{ app: 'Google Chrome' },
4646
]);
@@ -53,7 +53,7 @@ describe('runOpen util', () => {
5353
{ open: 'Google Chrome', openPage: '/index.html' },
5454
console
5555
).then(() => {
56-
expect(opn.mock.calls[0]).toEqual([
56+
expect(open.mock.calls[0]).toEqual([
5757
'https://example.com/index.html',
5858
{ app: 'Google Chrome' },
5959
]);
@@ -65,7 +65,7 @@ describe('runOpen util', () => {
6565
const logMock = { warn: jest.fn() };
6666

6767
beforeEach(() => {
68-
opn.mockImplementation(() => Promise.reject());
68+
open.mockImplementation(() => Promise.reject());
6969
});
7070

7171
afterEach(() => {
@@ -77,7 +77,7 @@ describe('runOpen util', () => {
7777
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
7878
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
7979
);
80-
expect(opn.mock.calls[0]).toEqual(['https://example.com', {}]);
80+
expect(open.mock.calls[0]).toEqual(['https://example.com', {}]);
8181
});
8282
});
8383

@@ -90,7 +90,7 @@ describe('runOpen util', () => {
9090
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
9191
`"Unable to open browser. If you are running in a headless environment, please do not use the --open flag"`
9292
);
93-
expect(opn.mock.calls[0]).toEqual([
93+
expect(open.mock.calls[0]).toEqual([
9494
'https://example.com/index.html',
9595
{},
9696
]);
@@ -106,7 +106,7 @@ describe('runOpen util', () => {
106106
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
107107
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
108108
);
109-
expect(opn.mock.calls[0]).toEqual([
109+
expect(open.mock.calls[0]).toEqual([
110110
'https://example.com',
111111
{
112112
app: 'Google Chrome',
@@ -124,7 +124,7 @@ describe('runOpen util', () => {
124124
expect(logMock.warn.mock.calls[0][0]).toMatchInlineSnapshot(
125125
`"Unable to open browser: Google Chrome. If you are running in a headless environment, please do not use the --open flag"`
126126
);
127-
expect(opn.mock.calls[0]).toEqual([
127+
expect(open.mock.calls[0]).toEqual([
128128
'https://example.com/index.html',
129129
{ app: 'Google Chrome' },
130130
]);

0 commit comments

Comments
 (0)