Files
docs/悦/PDA(海外)/tests/section-routing.runtime.test.js
2026-09-08 14:05:30 +08:00

22 lines
916 B
JavaScript

const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const applicationSource = fs.readFileSync(path.join(__dirname, '..', 'assets', 'app.js'), 'utf8')
.replace(/\s*bootstrap\(\);\s*$/, '');
const routingTest = String.raw`
render=()=>{};
toast=()=>{};
quickLogin('W001');
assert.equal(state.page,'receive-list');
assert.equal(state.user.id,'W001');
process.stdout.write('PASS: signing in from a section page opens that section\n');
`;
const storage = { getItem: () => null, setItem: () => {}, removeItem: () => {} };
const document = { body: { dataset: { section: 'receive' } }, getElementById: () => null };
const window = { location: { pathname: '/receive.html', href: '' }, scrollTo: () => {} };
const run = new Function('assert', 'localStorage', 'document', 'window', applicationSource + '\n' + routingTest);
run(assert, storage, document, window);