Cleanup and starting to implements tracks.

This commit is contained in:
vdv committed 2022-11-07 22:12:50 +01:00
1 parent 36a3199b36
commit 26486b65b9
9 files changed
+225 -26

No files matched your search

+11 -2
View File
@@ -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');
});
});