Skip to content

Commit

Permalink
Fix sendMessage declaration and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
tusbar committed Jan 9, 2017
1 parent ee7311a commit 688020e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
1 change: 0 additions & 1 deletion decls/vars.js
Expand Up @@ -3,7 +3,6 @@ declare var chrome: {
connect: (options: {name: string}) => Connection,
sendMessage: (
msg: any,
sender?: ?string,
cb?: (res: Object) => void
) => void,
onConnect: {
Expand Down
2 changes: 1 addition & 1 deletion src/ui-store.js
Expand Up @@ -47,7 +47,7 @@ export default function (): Promise<Store> {

// return promise to allow getting current state of "background" store
return new Promise(resolve => {
chrome.runtime.sendMessage({type: UPDATE_STATE}, null, res => {
chrome.runtime.sendMessage({type: UPDATE_STATE}, res => {
state = res;

// return an object with equivalent to Redux store interface
Expand Down
4 changes: 2 additions & 2 deletions tests/ui-store.js
Expand Up @@ -23,9 +23,9 @@ async function createStore(state) {

expect(chrome.runtime.connect).lastCalledWith({name: CONNECTION_NAME});
expect(connection.onMessage.addListener).lastCalledWith(jasmine.any(Function));
expect(chrome.runtime.sendMessage).lastCalledWith({type: UPDATE_STATE}, null, jasmine.any(Function));
expect(chrome.runtime.sendMessage).lastCalledWith({type: UPDATE_STATE}, jasmine.any(Function));

chrome.runtime.sendMessage.mock.calls[0][2](state);
chrome.runtime.sendMessage.mock.calls[0][1](state);

const store = await promise;

Expand Down

0 comments on commit 688020e

Please sign in to comment.