Files

18 lines
1.2 KiB
JavaScript
Raw Permalink Normal View History

import test from 'node:test';
import assert from 'node:assert/strict';
import { volumeSyncMessage } from '../src/components/device-volume-state.ts';
import { memorySection } from '../src/pages/memory-section.ts';
const twin = (revision, actual) => ({ desired_revision: 19, reported_revision: revision, desired_config: { volume: { speaker: 56 } }, reported_config: { volume: { speaker: actual } } });
test('volume confirms only the matching actual value and revision', () => {
assert.match(volumeSyncMessage(twin(19, 56), true), /已生效/);
assert.match(volumeSyncMessage(twin(18, 56), true), /等待设备确认/);
assert.match(volumeSyncMessage(twin(19, 55), true), /等待设备确认/);
assert.match(volumeSyncMessage(twin(18, 55), false), /上线后/);
assert.match(volumeSyncMessage(undefined), /读取/);
assert.match(volumeSyncMessage({ ...twin(19, 0), desired_config: { volume: { speaker: 0 } } }), /已生效/);
});
test('daily and long-term memory categories cover all supported types', () => {
for (const type of ['EVENT', 'OPEN_ITEM', 'INTERACTION']) assert.equal(memorySection(type), 'daily');
for (const type of ['PROFILE', 'PREFERENCE', 'RELATIONSHIP', 'STORY']) assert.equal(memorySection(type), 'memory');
});