test: add html style integrity checks
This commit is contained in:
parent
774c927b28
commit
9ee1675d3c
11
tests/html-integrity-v1774.mjs
Normal file
11
tests/html-integrity-v1774.mjs
Normal file
@ -0,0 +1,11 @@
|
||||
import fs from 'node:fs';
|
||||
const html=fs.readFileSync('public/index.html','utf8');
|
||||
let bad=0;
|
||||
const check=(value,message)=>{console.log(`${value?'OK':'FAIL'}: ${message}`);if(!value)bad++};
|
||||
const opens=(html.match(/<style(?:\s|>)/gi)||[]).length;
|
||||
const closes=(html.match(/<\/style>/gi)||[]).length;
|
||||
check(opens===closes,`style tags balanced (${opens} open / ${closes} close)`);
|
||||
check(!html.includes('}<style id="sun-composition-v1757">'),'mobile style is not nested into composition style');
|
||||
check(html.includes('}</style><style id="sun-composition-v1757">'),'mobile style closes before composition style');
|
||||
check(/<\/style>\s*<\/head>/i.test(html),'last head style is closed before </head>');
|
||||
if(bad)process.exit(1);
|
||||
Loading…
Reference in New Issue
Block a user