36 lines
1.5 KiB
TypeScript
36 lines
1.5 KiB
TypeScript
import { test } from 'node:test';
|
|||
|
|
import assert from 'node:assert/strict';
|
||
|
|
import { isCarriedStateType, stateToCarry } from './roomUpgradeState';
|
||
|
|
|
||
|
|
const ev = (type: string, content: Record<string, unknown>, stateKey = '') => ({
|
||
|
|
getType: () => type,
|
||
|
|
getStateKey: () => stateKey,
|
||
|
|
getContent: () => content,
|
||
|
|
});
|
||
|
|
|
||
|
|
test('Lotus room state is carried; state Synapse already copies is not (#327)', () => {
|
||
|
|
assert.equal(isCarriedStateType('io.lotus.voice_limit'), true);
|
||
|
|
assert.equal(isCarriedStateType('io.lotus.room_quality'), true);
|
||
|
|
assert.equal(isCarriedStateType('io.lotus.soundboard'), true);
|
||
|
|
assert.equal(isCarriedStateType('m.room.retention'), true);
|
||
|
|
assert.equal(isCarriedStateType('in.cinny.room.power_level_tags'), true);
|
||
|
|
assert.equal(isCarriedStateType('im.ponies.room_emotes'), true);
|
||
|
|
assert.equal(isCarriedStateType('m.room.power_levels'), false);
|
||
|
|
assert.equal(isCarriedStateType('m.room.name'), false);
|
||
|
|
assert.equal(isCarriedStateType('m.room.member'), false);
|
||
|
|
});
|
||
|
|
|
||
|
|
test('stateToCarry keeps state keys and skips emptied events', () => {
|
||
|
|
const out = stateToCarry([
|
||
|
|
ev('io.lotus.voice_limit', { max_users: 5 }),
|
||
|
|
ev('io.lotus.soundboard', { clips: [1] }, 'pack-a'),
|
||
|
|
ev('io.lotus.room_quality', {}),
|
||
|
|
ev('m.room.name', { name: 'x' }),
|
||
|
|
ev('m.room.retention', { max_lifetime: 604800000 }),
|
||
|
|
]);
|
||
|
|
assert.deepEqual(
|
||
|
|
out.map((s) => `${s.type}|${s.stateKey}`),
|
||
|
|
['io.lotus.voice_limit|', 'io.lotus.soundboard|pack-a', 'm.room.retention|'],
|
||
|
|
);
|
||
|
|
});
|