Skip to content

Commit 917a4ec

Browse files
committed
test: updates
1 parent 5bf4929 commit 917a4ec

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

client-src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,14 @@ const onSocketMessage = {
136136
// TODO: remove in v5 in favor of 'static-changed'
137137
'content-changed': function contentChanged(file) {
138138
log.info(
139-
`${file || 'Contents'} from static directory were changed. Reloading...`
139+
`${file || 'Content'} from static directory was changed. Reloading...`
140140
);
141141

142142
self.location.reload();
143143
},
144144
'static-changed': function staticChanged(file) {
145145
log.info(
146-
`${file || 'Contents'} from static directory were changed. Reloading...`
146+
`${file || 'Content'} from static directory was changed. Reloading...`
147147
);
148148

149149
self.location.reload();

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ Array [
7676
]
7777
`;
7878

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

81-
exports[`index should run onSocketMessage['static-changed'] 1`] = `"Contents from static directory were changed. Reloading..."`;
81+
exports[`index should run onSocketMessage['static-changed'] 1`] = `"Content from static directory was changed. Reloading..."`;
82+
83+
exports[`index should run onSocketMessage['static-changed'](file) 1`] = `"/static/assets/index.html from static directory was changed. Reloading..."`;
8284

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

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

+4-2
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,11 @@ Array [
7676
]
7777
`;
7878

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

81-
exports[`index should run onSocketMessage['static-changed'] 1`] = `"Contents from static directory were changed. Reloading..."`;
81+
exports[`index should run onSocketMessage['static-changed'] 1`] = `"Content from static directory was changed. Reloading..."`;
82+
83+
exports[`index should run onSocketMessage['static-changed'](file) 1`] = `"/static/assets/index.html from static directory was changed. Reloading..."`;
8284

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

test/client/index.test.js

+7
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ describe('index', () => {
173173
expect(self.location.reload).toBeCalled();
174174
});
175175

176+
test("should run onSocketMessage['static-changed'](file)", () => {
177+
onSocketMessage['static-changed']('/static/assets/index.html');
178+
179+
expect(log.log.info.mock.calls[0][0]).toMatchSnapshot();
180+
expect(self.location.reload).toBeCalled();
181+
});
182+
176183
test('should run onSocketMessage.warnings', () => {
177184
{
178185
const res = onSocketMessage.warnings([

0 commit comments

Comments
 (0)