mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Add near 100% unit test coverage for webclient websocket layer
This commit is contained in:
parent
8cc65b8967
commit
35be723ebf
26 changed files with 3932 additions and 0 deletions
37
webclient/src/websocket/persistence/AdminPersistence.spec.ts
Normal file
37
webclient/src/websocket/persistence/AdminPersistence.spec.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
jest.mock('store', () => ({
|
||||
ServerDispatch: {
|
||||
adjustMod: jest.fn(),
|
||||
reloadConfig: jest.fn(),
|
||||
shutdownServer: jest.fn(),
|
||||
updateServerMessage: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
import { AdminPersistence } from './AdminPersistence';
|
||||
import { ServerDispatch } from 'store';
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('AdminPersistence', () => {
|
||||
it('adjustMod passes userName, shouldBeMod, shouldBeJudge', () => {
|
||||
AdminPersistence.adjustMod('alice', true, false);
|
||||
expect(ServerDispatch.adjustMod).toHaveBeenCalledWith('alice', true, false);
|
||||
});
|
||||
|
||||
it('reloadConfig -> ServerDispatch.reloadConfig', () => {
|
||||
AdminPersistence.reloadConfig();
|
||||
expect(ServerDispatch.reloadConfig).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('shutdownServer -> ServerDispatch.shutdownServer', () => {
|
||||
AdminPersistence.shutdownServer();
|
||||
expect(ServerDispatch.shutdownServer).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('updateServerMessage -> ServerDispatch.updateServerMessage', () => {
|
||||
AdminPersistence.updateServerMessage();
|
||||
expect(ServerDispatch.updateServerMessage).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue