Removing tests which hadn't been updated since React (shame on me).

This commit is contained in:
vdv committed 2023-02-07 16:47:26 +01:00
1 parent 57010f89f4
commit 03c0476f46
12 files changed
-937

No files matched your search

-37
View File
@@ -1,37 +0,0 @@
import dispatch, { init, worker } from './dispatcher-main';
jest.mock('./get-worker', () => ({
getWorker: () => ({
port: {
postMessage: jest.fn(),
},
}),
}));
describe('The dispatcher-main', () => {
beforeEach(() => {
init();
});
test('should create a new shared web worker', () => {
expect(worker).toBeDefined();
});
test('should create a onmessage function', () => {
expect(worker.port.onmessage).toBeDefined();
});
test('should return a promise if no callback is provided', () => {
expect(dispatch('ping')).toBeInstanceOf(Promise);
});
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');
});
});
-33
View File
@@ -1,33 +0,0 @@
import worker from './dispatcher-worker';
jest.mock('../db', () => ({
initDb: () => 'called initDb',
}));
describe('The dispatcher-worker ', () => {
let port;
beforeEach(() => {
port = {
postMessage: jest.fn(),
};
worker.onconnect({ ports: [port] });
});
test('creates a onmessage function', () => {
expect(port.onmessage).toBeDefined();
expect(port.postMessage).not.toBeCalled();
});
test('receives a ping and sends back an unknownAction', async () => {
await port.onmessage({ data: { id: 5, payload: { action: 'ping' } } });
expect(port.postMessage).toBeCalledWith({
id: 5,
payload: 'unknownAction',
});
});
test('calls initDb when required', async () => {
await port.onmessage({ data: { id: 5, payload: { action: 'initDb' } } });
expect(port.postMessage).toBeCalledWith({
id: 5,
payload: 'called initDb',
});
});
});