Skip to content

Commit 072936b

Browse files
committed
test(client): updated cli and index tests
1 parent 620a052 commit 072936b

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

test/cli/cli.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ describe('CLI', () => {
6161
testBin('--sockPath /mysockPath')
6262
.then((output) => {
6363
expect(
64-
output.stdout.includes('http://localhost&sockPath=/mysockPath')
64+
output.stdout.includes(
65+
`http://localhost?sockPath=${encodeURIComponent('/mysockPath')}`
66+
)
6567
).toEqual(true);
6668
done();
6769
})

test/client/__snapshots__/index.test.js.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@ exports[`index should run onSocketMessage['still-ok'] 1`] = `"[WDS] Nothing chan
7474

7575
exports[`index should run onSocketMessage['still-ok'] 2`] = `"StillOk"`;
7676

77+
exports[`index should run updatePublicPath 1`] = `
78+
Array [
79+
"foo",
80+
]
81+
`;
82+
7783
exports[`index should set arguments into socket function 1`] = `
7884
Array [
7985
"mock-url",

test/client/index.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ describe('index', () => {
1313
let reloadApp;
1414
let sendMessage;
1515
let onSocketMessage;
16+
let updatePublicPath;
1617
const locationValue = self.location;
1718
const resourceQueryValue = global.__resourceQuery;
1819

@@ -55,6 +56,13 @@ describe('index', () => {
5556
() => 'mock-url'
5657
);
5758

59+
// updatePublicPath
60+
jest.setMock(
61+
'../../client-src/default/utils/updatePublicPath.js',
62+
jest.fn()
63+
);
64+
updatePublicPath = require('../../client-src/default/utils/updatePublicPath');
65+
5866
require('../../client-src/default');
5967
onSocketMessage = socket.mock.calls[0][1];
6068
});
@@ -215,4 +223,9 @@ describe('index', () => {
215223
expect(log.log.error.mock.calls[0][0]).toMatchSnapshot();
216224
expect(sendMessage.mock.calls[0][0]).toMatchSnapshot();
217225
});
226+
227+
test('should run updatePublicPath', () => {
228+
expect(updatePublicPath).toBeCalled();
229+
expect(updatePublicPath.mock.calls[0]).toMatchSnapshot();
230+
});
218231
});

0 commit comments

Comments
 (0)