mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
harden implementations
This commit is contained in:
parent
c3ae4cffd6
commit
559a3ff1f4
25 changed files with 240 additions and 37 deletions
|
|
@ -322,6 +322,39 @@ describe('connectionClosed', () => {
|
|||
connectionClosed({ reason: 7 } as any);
|
||||
expect(SessionCmds.updateStatus).toHaveBeenCalledWith(expect.anything(), 'Unknown reason');
|
||||
});
|
||||
|
||||
it('BANNED with valid positive endTime → shows formatted date', () => {
|
||||
connectionClosed({ reason: 2, endTime: 1700000000 } as any);
|
||||
expect(SessionCmds.updateStatus).toHaveBeenCalledWith(
|
||||
expect.anything(),
|
||||
expect.stringContaining('You are banned until')
|
||||
);
|
||||
});
|
||||
|
||||
it('BANNED with endTime = 0 → shows generic banned message', () => {
|
||||
connectionClosed({ reason: 2, endTime: 0 } as any);
|
||||
expect(SessionCmds.updateStatus).toHaveBeenCalledWith(expect.anything(), 'You are banned');
|
||||
});
|
||||
|
||||
it('BANNED with endTime = -1 → shows generic banned message', () => {
|
||||
connectionClosed({ reason: 2, endTime: -1 } as any);
|
||||
expect(SessionCmds.updateStatus).toHaveBeenCalledWith(expect.anything(), 'You are banned');
|
||||
});
|
||||
|
||||
it('BANNED with endTime = NaN → shows generic banned message', () => {
|
||||
connectionClosed({ reason: 2, endTime: NaN } as any);
|
||||
expect(SessionCmds.updateStatus).toHaveBeenCalledWith(expect.anything(), 'You are banned');
|
||||
});
|
||||
|
||||
it('BANNED with endTime = Infinity → shows generic banned message', () => {
|
||||
connectionClosed({ reason: 2, endTime: Infinity } as any);
|
||||
expect(SessionCmds.updateStatus).toHaveBeenCalledWith(expect.anything(), 'You are banned');
|
||||
});
|
||||
|
||||
it('BANNED with reasonStr → uses reasonStr regardless of endTime', () => {
|
||||
connectionClosed({ reason: 2, endTime: 0, reasonStr: 'custom ban reason' } as any);
|
||||
expect(SessionCmds.updateStatus).toHaveBeenCalledWith(expect.anything(), 'custom ban reason');
|
||||
});
|
||||
});
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue