add offline support
This commit is contained in:
@@ -16,13 +16,16 @@ async function clientSources() {
|
||||
return Promise.all(names.filter(name => name.endsWith('.js')).map(name => read(`public/js/${name}`)));
|
||||
}
|
||||
|
||||
test('every static HTML id is referenced by authored client JavaScript', async () => {
|
||||
test('every static HTML id is referenced by client JavaScript or accessible HTML relationships', async () => {
|
||||
const html = await read('public/index.html');
|
||||
const scripts = (await clientSources()).join('\n');
|
||||
const ids = [...html.matchAll(/\bid="([^"]+)"/g)].map(match => match[1]);
|
||||
const htmlReferences = new Set([...html.matchAll(/\b(?:aria-labelledby|aria-describedby|aria-controls|for)="([^"]+)"/g)]
|
||||
.flatMap(match => match[1].split(/\s+/)));
|
||||
|
||||
assert.ok(ids.length > 0);
|
||||
for (const id of ids) {
|
||||
if (htmlReferences.has(id)) continue;
|
||||
assert.match(scripts, new RegExp(id.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')), `unused id: ${id}`);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user