Skip to content

Commit

Permalink
test: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 committed May 24, 2021
1 parent 5bf4929 commit 917a4ec
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions client-src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,14 @@ const onSocketMessage = {
// TODO: remove in v5 in favor of 'static-changed'
'content-changed': function contentChanged(file) {
log.info(
`${file || 'Contents'} from static directory were changed. Reloading...`
`${file || 'Content'} from static directory was changed. Reloading...`
);

self.location.reload();
},
'static-changed': function staticChanged(file) {
log.info(
`${file || 'Contents'} from static directory were changed. Reloading...`
`${file || 'Content'} from static directory was changed. Reloading...`
);

self.location.reload();
Expand Down
6 changes: 4 additions & 2 deletions test/client/__snapshots__/index.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ Array [
]
`;

exports[`index should run onSocketMessage['content-changed'] 1`] = `"Content base changed. Reloading..."`;
exports[`index should run onSocketMessage['content-changed'] 1`] = `"Content from static directory was changed. Reloading..."`;

exports[`index should run onSocketMessage['static-changed'] 1`] = `"Contents from static directory were changed. Reloading..."`;
exports[`index should run onSocketMessage['static-changed'] 1`] = `"Content from static directory was changed. Reloading..."`;

exports[`index should run onSocketMessage['static-changed'](file) 1`] = `"/static/assets/index.html from static directory was changed. Reloading..."`;

exports[`index should run onSocketMessage['still-ok'] 1`] = `"Nothing changed."`;

Expand Down
6 changes: 4 additions & 2 deletions test/client/__snapshots__/index.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ Array [
]
`;

exports[`index should run onSocketMessage['content-changed'] 1`] = `"Content base changed. Reloading..."`;
exports[`index should run onSocketMessage['content-changed'] 1`] = `"Content from static directory was changed. Reloading..."`;

exports[`index should run onSocketMessage['static-changed'] 1`] = `"Contents from static directory were changed. Reloading..."`;
exports[`index should run onSocketMessage['static-changed'] 1`] = `"Content from static directory was changed. Reloading..."`;

exports[`index should run onSocketMessage['static-changed'](file) 1`] = `"/static/assets/index.html from static directory was changed. Reloading..."`;

exports[`index should run onSocketMessage['still-ok'] 1`] = `"Nothing changed."`;

Expand Down
7 changes: 7 additions & 0 deletions test/client/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ describe('index', () => {
expect(self.location.reload).toBeCalled();
});

test("should run onSocketMessage['static-changed'](file)", () => {
onSocketMessage['static-changed']('/static/assets/index.html');

expect(log.log.info.mock.calls[0][0]).toMatchSnapshot();
expect(self.location.reload).toBeCalled();
});

test('should run onSocketMessage.warnings', () => {
{
const res = onSocketMessage.warnings([
Expand Down

0 comments on commit 917a4ec

Please sign in to comment.