3
3
*/
4
4
import { parse , TextNode } from 'node-html-parser' ;
5
5
import { readFile } from 'node:fs/promises' ;
6
-
7
- class Visitor {
8
- constructor ( { condition, accumulator, props} ) {
9
- this . condition = condition ;
10
- this . accumulator = accumulator ;
11
- this . props = props ;
12
- }
13
- visit ( { nodes} ) {
14
- for ( const node of nodes ) {
15
- if ( this . condition ( node ) ) {
16
- this . accumulator . push ( node ) ;
17
- }
18
- for ( const prop of this . props ) {
19
- if ( node [ prop ] ) {
20
- this . visit ( { nodes : node [ prop ] } ) ;
21
- }
22
- }
23
- }
24
- }
25
- }
6
+ import { Visitor } from './Visitor.js' ;
26
7
27
8
export async function checkSpecText ( { specUrl, suiteLog} ) {
28
9
const specUrls = Array . isArray ( specUrl ) ? specUrl : [ specUrl ] ;
@@ -45,13 +26,12 @@ export async function checkSpecText({specUrl, suiteLog}) {
45
26
if ( suiteLog ) {
46
27
log = JSON . parse ( await readFile ( suiteLog ) ) ;
47
28
}
48
- //console.log(accumulator);
49
29
if ( log ) {
50
30
testVisitor . visit ( { nodes : log . suites } ) ;
51
31
testVisitor . visit ( { nodes : log . tests } ) ;
52
32
}
53
33
const testTitles = new Set ( tests . map ( test => test ?. title ) ) ;
54
- const normStatements = new Set ( statements ) ;
34
+ const normStatements = new Set ( statements . map ( s => s . text ) ) ;
55
35
console . log ( `Test Title Count ${ testTitles . size } ` ) ;
56
36
console . log ( `Normative Statement Count ${ normStatements . size } ` ) ;
57
37
}
0 commit comments