Via subagent, all verified, no bugs: - state/toast (7), room-list/roomList (6), inviteList (6), room-list/utils compareRoomsEqual (6), backupRestore (6), callEmbed dispose-on-replace (6), closedNavCategories factory + makeNavCategoryId (8). - features/room/msgContent (5): getAudioMsgContent/getFileMsgContent incl. encrypted (content.file) vs plain (content.url) branch. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { compareRoomsEqual } from './utils';
|
|
|
|
// compareRoomsEqual(a, b): length mismatch short-circuits to false, otherwise an
|
|
// order-sensitive element-by-element equality. The React hook in the same file
|
|
// (useBindRoomsWithMembershipsAtom) is not covered.
|
|
|
|
test('two empty arrays are equal', () => {
|
|
assert.equal(compareRoomsEqual([], []), true);
|
|
});
|
|
|
|
test('identical arrays are equal', () => {
|
|
assert.equal(compareRoomsEqual(['a', 'b', 'c'], ['a', 'b', 'c']), true);
|
|
});
|
|
|
|
test('different lengths are not equal', () => {
|
|
assert.equal(compareRoomsEqual(['a', 'b'], ['a', 'b', 'c']), false);
|
|
assert.equal(compareRoomsEqual(['a'], []), false);
|
|
});
|
|
|
|
test('same elements in a different order are not equal (order-sensitive)', () => {
|
|
assert.equal(compareRoomsEqual(['a', 'b'], ['b', 'a']), false);
|
|
});
|
|
|
|
test('a single differing element makes them unequal', () => {
|
|
assert.equal(compareRoomsEqual(['a', 'b', 'c'], ['a', 'x', 'c']), false);
|
|
});
|
|
|
|
test('reference equality is not required, only value equality', () => {
|
|
const a = ['a', 'b'];
|
|
const b = ['a', 'b'];
|
|
assert.notEqual(a, b);
|
|
assert.equal(compareRoomsEqual(a, b), true);
|
|
});
|