Skip to content

Commit

Permalink
test(client): updated cli and index tests
Browse files Browse the repository at this point in the history
  • Loading branch information
knagaitsev committed Jun 22, 2019
1 parent 620a052 commit 072936b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/cli/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ describe('CLI', () => {
testBin('--sockPath /mysockPath')
.then((output) => {
expect(
output.stdout.includes('http://localhost&sockPath=/mysockPath')
output.stdout.includes(
`http://localhost?sockPath=${encodeURIComponent('/mysockPath')}`
)
).toEqual(true);
done();
})
Expand Down
6 changes: 6 additions & 0 deletions test/client/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ exports[`index should run onSocketMessage['still-ok'] 1`] = `"[WDS] Nothing chan

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

exports[`index should run updatePublicPath 1`] = `
Array [
"foo",
]
`;

exports[`index should set arguments into socket function 1`] = `
Array [
"mock-url",
Expand Down
13 changes: 13 additions & 0 deletions test/client/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('index', () => {
let reloadApp;
let sendMessage;
let onSocketMessage;
let updatePublicPath;
const locationValue = self.location;
const resourceQueryValue = global.__resourceQuery;

Expand Down Expand Up @@ -55,6 +56,13 @@ describe('index', () => {
() => 'mock-url'
);

// updatePublicPath
jest.setMock(
'../../client-src/default/utils/updatePublicPath.js',
jest.fn()
);
updatePublicPath = require('../../client-src/default/utils/updatePublicPath');

require('../../client-src/default');
onSocketMessage = socket.mock.calls[0][1];
});
Expand Down Expand Up @@ -215,4 +223,9 @@ describe('index', () => {
expect(log.log.error.mock.calls[0][0]).toMatchSnapshot();
expect(sendMessage.mock.calls[0][0]).toMatchSnapshot();
});

test('should run updatePublicPath', () => {
expect(updatePublicPath).toBeCalled();
expect(updatePublicPath.mock.calls[0]).toMatchSnapshot();
});
});

0 comments on commit 072936b

Please sign in to comment.