Add near 100% unit test coverage for webclient websocket layer

This commit is contained in:
seavor 2026-04-12 02:27:03 -05:00
parent 8cc65b8967
commit 35be723ebf
26 changed files with 3932 additions and 0 deletions

View 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();
});
});