All checks were successful
Queue Release Build / prepare (push) Successful in 15s
Deploy Web Apps / deploy (push) Successful in 6m54s
Queue Release Build / build-windows (push) Successful in 16m6s
Queue Release Build / build-linux (push) Successful in 30m58s
Queue Release Build / finalize (push) Successful in 44s
isolated users, db backup, weird disconnect issues for long voice sessions,
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import {
|
|
reconcileRoomSnapshotChannels,
|
|
sanitizeRoomSnapshot
|
|
} from './rooms.helpers';
|
|
|
|
describe('room snapshot helpers', () => {
|
|
it('drops empty channel arrays from outgoing snapshots', () => {
|
|
expect(sanitizeRoomSnapshot({ channels: [] }).channels).toBeUndefined();
|
|
});
|
|
|
|
it('keeps cached channels when incoming snapshot has none', () => {
|
|
const cachedChannels = [
|
|
{ id: 'general', name: 'general', type: 'text', position: 0 },
|
|
{ id: 'updates', name: 'updates', type: 'text', position: 1 }
|
|
] as const;
|
|
|
|
expect(reconcileRoomSnapshotChannels(cachedChannels as never, undefined)).toEqual(cachedChannels);
|
|
expect(reconcileRoomSnapshotChannels(cachedChannels as never, [] as never)).toEqual(cachedChannels);
|
|
});
|
|
|
|
it('keeps richer cached channels when incoming snapshot is smaller', () => {
|
|
const cachedChannels = [
|
|
{ id: 'general', name: 'general', type: 'text', position: 0 },
|
|
{ id: 'updates', name: 'updates', type: 'text', position: 1 },
|
|
{ id: 'voice', name: 'General', type: 'voice', position: 0 }
|
|
] as const;
|
|
const incomingChannels = [
|
|
{ id: 'general', name: 'general', type: 'text', position: 0 }
|
|
] as const;
|
|
|
|
expect(reconcileRoomSnapshotChannels(cachedChannels as never, incomingChannels as never)).toEqual(cachedChannels);
|
|
});
|
|
|
|
it('accepts incoming channels when snapshot is at least as complete', () => {
|
|
const cachedChannels = [
|
|
{ id: 'general', name: 'general', type: 'text', position: 0 }
|
|
] as const;
|
|
const incomingChannels = [
|
|
{ id: 'general', name: 'general', type: 'text', position: 0 },
|
|
{ id: 'updates', name: 'updates', type: 'text', position: 1 }
|
|
] as const;
|
|
|
|
expect(reconcileRoomSnapshotChannels(cachedChannels as never, incomingChannels as never)).toEqual(incomingChannels);
|
|
});
|
|
});
|