6e59395fb8
Subagent batch (no bugs found) + markdown: - lotus/avatarDecorations (8): decorationUrl, CDN shape, ALL_DECORATIONS flattening, data invariants (unique category ids + slugs, slug charset). - plugins/call/utils (7): getCallCapabilities — static caps + room/user/device scoped state-keys. - utils/matrix-crypto (3): verifiedDevice via a stubbed CryptoApi. - utils/featureCheck (3): checkIndexedDBSupport success/error/throw paths. - state/typingMembers (8): add/dedup-by-latest-ts/per-room-scope/delete reducer via a jotai store (enableMapSet, mirroring app startup). - plugins/markdown/utils (5): inline + block escape/unescape round-trips. Full suite now 231 tests, all passing. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { CryptoApi } from 'matrix-js-sdk/lib/crypto-api';
|
|
import { verifiedDevice } from './matrix-crypto';
|
|
|
|
// `verifiedDevice` only touches `api.getDeviceVerificationStatus`, so a tiny
|
|
// stub standing in for the real CryptoApi is enough to exercise the pure logic.
|
|
// Anything requiring an actual crypto backend (key import, cross-signing setup,
|
|
// etc.) is out of scope here and intentionally not covered.
|
|
const cryptoApi = (status: unknown): CryptoApi =>
|
|
({
|
|
getDeviceVerificationStatus: async () => status,
|
|
}) as unknown as CryptoApi;
|
|
|
|
test('verifiedDevice returns null when there is no verification status', async () => {
|
|
assert.equal(await verifiedDevice(cryptoApi(null), '@a:b', 'DEV'), null);
|
|
assert.equal(await verifiedDevice(cryptoApi(undefined), '@a:b', 'DEV'), null);
|
|
});
|
|
|
|
test('verifiedDevice surfaces crossSigningVerified when status exists', async () => {
|
|
assert.equal(
|
|
await verifiedDevice(cryptoApi({ crossSigningVerified: true }), '@a:b', 'DEV'),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
await verifiedDevice(cryptoApi({ crossSigningVerified: false }), '@a:b', 'DEV'),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test('verifiedDevice forwards userId and deviceId to the crypto api', async () => {
|
|
let received: [string, string] | undefined;
|
|
const api = {
|
|
getDeviceVerificationStatus: async (userId: string, deviceId: string) => {
|
|
received = [userId, deviceId];
|
|
return { crossSigningVerified: true };
|
|
},
|
|
} as unknown as CryptoApi;
|
|
|
|
await verifiedDevice(api, '@alice:example.org', 'ABCDEF');
|
|
assert.deepEqual(received, ['@alice:example.org', 'ABCDEF']);
|
|
});
|