import test from 'node:test'; import assert from 'node:assert/strict'; import { readPhoneCode } from '../../YouleNexus/assets/framework/adapters/native/phone-code.ts'; test('original phone cache restores the number and 30-second remainder without auto-filling the code',()=>{ const raw=JSON.stringify({phoneNumber:'0013800138000',code:'1234',codeTime:1000}); assert.deepEqual(readPhoneCode(raw,2500),{phoneNumber:'0013800138000',restTime:28}); assert.deepEqual(readPhoneCode(raw,31000),{phoneNumber:'0013800138000',restTime:0}); assert.deepEqual(readPhoneCode(raw,32000),{phoneNumber:'0013800138000',restTime:0}); assert.equal(readPhoneCode(null,32000),null); }); test('malformed phone cache exposes the source error',()=>{ assert.throws(()=>readPhoneCode('{',100),SyntaxError); assert.throws(()=>readPhoneCode(JSON.stringify({phoneNumber:'123',codeTime:'bad'}),100),/codeTime/); });