Cleanup and starting to implements tracks.
This commit is contained in:
1 parent
36a3199b36
commit
26486b65b9
9 files changed
+225
-26
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import dispatch, { init, worker } from './dispatcher-main'
|
||||
import dispatch, { init, worker } from './dispatcher-main';
|
||||
|
||||
jest.mock('./get-worker', () => ({
|
||||
getWorker: () => ({
|
||||
@@ -21,8 +21,17 @@ describe('The dispatcher-main', () => {
|
||||
test('should return a promise if no callback is provided', () => {
|
||||
expect(dispatch('ping')).toBeInstanceOf(Promise);
|
||||
});
|
||||
test('should send back the message', () => {
|
||||
test('should forward the message', () => {
|
||||
dispatch('ping');
|
||||
expect(worker.port.postMessage).toBeCalledWith({ id: 0, payload: 'ping' });
|
||||
});
|
||||
test('should return the response', () => {
|
||||
var response;
|
||||
const callback = (error, success) => {
|
||||
response = success;
|
||||
};
|
||||
dispatch('ping', callback);
|
||||
worker.port.onmessage({ data: { id: 0, payload: 'pong' } });
|
||||
expect(response).toEqual('pong');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user