29 lines
1.0 KiB
TypeScript
29 lines
1.0 KiB
TypeScript
import { test } from 'node:test';
|
|||
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { voiceChannelOccupancy } from './voiceChannelFull';
|
||
|
|
|
||
|
|
test('voiceChannelOccupancy: one user on two devices fills one slot, not two', () => {
|
||
|
|
assert.deepEqual(voiceChannelOccupancy(['@a:x', '@a:x'], '@b:x', 2), {
|
||
|
|
channelFull: false,
|
||
|
|
current: 1,
|
||
|
|
max: 2,
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
test('voiceChannelOccupancy: full when distinct users reach the limit', () => {
|
||
|
|
assert.deepEqual(voiceChannelOccupancy(['@a:x', '@c:x', '@a:x'], '@b:x', 2), {
|
||
|
|
channelFull: true,
|
||
|
|
current: 2,
|
||
|
|
max: 2,
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
test('voiceChannelOccupancy: someone already in the call can always join another device', () => {
|
||
|
|
assert.equal(voiceChannelOccupancy(['@a:x', '@b:x'], '@b:x', 2).channelFull, false);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('voiceChannelOccupancy: no limit (0) is never full; unknown senders are ignored', () => {
|
||
|
|
assert.equal(voiceChannelOccupancy(['@a:x', '@c:x'], '@b:x', 0).channelFull, false);
|
||
|
|
assert.equal(voiceChannelOccupancy([undefined, '@a:x'], '@b:x', 2).current, 1);
|
||
|
|
});
|