Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BREAK CHANGES(cleint): rename keynames to camelCase #2734

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client-src/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const onSocketMessage = {
hash(hash) {
status.currentHash = hash;
},
'still-ok': function stillOk() {
stillOk() {
log.info('Nothing changed.');
if (options.useWarningOverlay || options.useErrorOverlay) {
overlay.clear();
Expand Down Expand Up @@ -91,7 +91,7 @@ const onSocketMessage = {
options.useProgress = progress;
}
},
'progress-update': function progressUpdate(data) {
progressUpdate(data) {
if (options.useProgress) {
log.info(`${data.percent}% - ${data.msg}.`);
}
Expand All @@ -107,7 +107,7 @@ const onSocketMessage = {
}
reloadApp(options, status);
},
'content-changed': function contentChanged() {
contentChanged() {
log.info('Content base changed. Reloading...');
self.location.reload();
},
Expand Down
8 changes: 4 additions & 4 deletions lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ class Server {
msg = `${msg} (${addInfo})`;
}

this.sockWrite(this.sockets, 'progress-update', { percent, msg });
this.sockWrite(this.sockets, 'progressUpdate', { percent, msg });

if (this.listeningApp) {
this.listeningApp.emit('progress-update', { percent, msg });
this.listeningApp.emit('progressUpdate', { percent, msg });
}
}).apply(this.compiler);
}
Expand Down Expand Up @@ -813,7 +813,7 @@ class Server {
stats.assets.every((asset) => !asset.emitted);

if (shouldEmit) {
return this.sockWrite(sockets, 'still-ok');
return this.sockWrite(sockets, 'stillOk');
}

this.sockWrite(sockets, 'hash', stats.hash);
Expand Down Expand Up @@ -855,7 +855,7 @@ class Server {
// disabling refreshing on changing the content
if (this.options.liveReload) {
watcher.on('change', () => {
this.sockWrite(this.sockets, 'content-changed');
this.sockWrite(this.sockets, 'contentChanged');
});
}
this.contentBaseWatchers.push(watcher);
Expand Down
22 changes: 11 additions & 11 deletions test/client/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ exports[`index should run onSocketMessage.close 1`] = `"Disconnected!"`;

exports[`index should run onSocketMessage.close 2`] = `"Close"`;

exports[`index should run onSocketMessage.contentChanged 1`] = `"Content base changed. Reloading..."`;

exports[`index should run onSocketMessage.error 1`] = `"error!!"`;

exports[`index should run onSocketMessage.errors 1`] = `"Errors while compiling. Reload prevented."`;
Expand Down Expand Up @@ -54,9 +56,13 @@ Object {
}
`;

exports[`index should run onSocketMessage.progress and onSocketMessage['progress-update'] 1`] = `"Progress"`;
exports[`index should run onSocketMessage.progress and onSocketMessage.progressUpdate 1`] = `"Progress"`;

exports[`index should run onSocketMessage.progress and onSocketMessage.progressUpdate 2`] = `"12% - mock-msg."`;

exports[`index should run onSocketMessage.stillOk 1`] = `"Nothing changed."`;

exports[`index should run onSocketMessage.progress and onSocketMessage['progress-update'] 2`] = `"12% - mock-msg."`;
exports[`index should run onSocketMessage.stillOk 2`] = `"StillOk"`;

exports[`index should run onSocketMessage.warnings 1`] = `"Warnings while compiling."`;

Expand All @@ -76,18 +82,12 @@ Array [
]
`;

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

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

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

exports[`index should set arguments into socket function 1`] = `
Array [
"mock-url",
Object {
"close": [Function],
"content-changed": [Function],
"contentChanged": [Function],
"error": [Function],
"errors": [Function],
"hash": [Function],
Expand All @@ -98,8 +98,8 @@ Array [
"ok": [Function],
"overlay": [Function],
"progress": [Function],
"progress-update": [Function],
"still-ok": [Function],
"progressUpdate": [Function],
"stillOk": [Function],
"warnings": [Function],
},
]
Expand Down
16 changes: 8 additions & 8 deletions test/client/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ describe('index', () => {
expect(overlay.clear).toBeCalled();
});

test("should run onSocketMessage['still-ok']", () => {
onSocketMessage['still-ok']();
test('should run onSocketMessage.stillOk', () => {
onSocketMessage.stillOk();
expect(log.log.info.mock.calls[0][0]).toMatchSnapshot();
expect(sendMessage.mock.calls[0][0]).toMatchSnapshot();
expect(overlay.clear).not.toBeCalled();

// change flags
onSocketMessage.overlay(true);
onSocketMessage['still-ok']();
onSocketMessage.stillOk();
expect(overlay.clear).toBeCalled();
});

Expand All @@ -111,17 +111,17 @@ describe('index', () => {
onSocketMessage.logging();
});

test("should run onSocketMessage.progress and onSocketMessage['progress-update']", () => {
test('should run onSocketMessage.progress and onSocketMessage.progressUpdate', () => {
onSocketMessage.progress(false);
onSocketMessage['progress-update']({
onSocketMessage.progressUpdate({
msg: 'mock-msg',
percent: '12',
});
expect(log.log.info).not.toBeCalled();
expect(sendMessage.mock.calls[0][0]).toMatchSnapshot();

onSocketMessage.progress(true);
onSocketMessage['progress-update']({
onSocketMessage.progressUpdate({
msg: 'mock-msg',
percent: '12',
});
Expand Down Expand Up @@ -159,8 +159,8 @@ describe('index', () => {
}
});

test("should run onSocketMessage['content-changed']", () => {
onSocketMessage['content-changed']();
test('should run onSocketMessage.contentChanged', () => {
onSocketMessage.contentChanged();

expect(log.log.info.mock.calls[0][0]).toMatchSnapshot();
expect(self.location.reload).toBeCalled();
Expand Down
2 changes: 1 addition & 1 deletion test/server/progress-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('progress', () => {
compiler.run(() => {});
const app = server.listen(port, 'localhost');

app.on('progress-update', ({ percent, msg }) => {
app.on('progressUpdate', ({ percent, msg }) => {
expect(percent).toBeGreaterThanOrEqual(0);
expect(percent).toBeLessThanOrEqual(100);
expect(typeof msg).toEqual('string');
Expand Down