import test from 'node:test'; import assert from 'node:assert/strict'; import { configurationDateTime, currentConfigurationName } from '../src/configurationName.ts'; test('date names use Shanghai time rather than the device timezone',()=>{ assert.equal(configurationDateTime('2026-12-31T16:00:00Z'),'2027-01-01 00:00:00'); assert.equal(configurationDateTime('2026-10-21T05:57:31.164921Z'),'2026-10-21 13:57:31'); }); test('legacy configurations display their own creation time, not the current time',()=>{ assert.equal(currentConfigurationName('原规则名称','2026-10-21T05:57:31Z'),'2026-10-21 13:57:31'); assert.equal(currentConfigurationName('旧记录',undefined),''); assert.equal(configurationDateTime('invalid'),''); }); test('the server generated date name stays stable when its creation time is a few seconds later',()=>{ assert.equal(currentConfigurationName('2026-10-29 14:05:30','2026-10-29T06:05:35Z'),'2026-10-29 14:05:30'); });