-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-parser.ts
More file actions
98 lines (89 loc) · 3.04 KB
/
Copy pathtest-parser.ts
File metadata and controls
98 lines (89 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* Test script for the parser functions
*/
import {
parseRisk,
listAllRisks,
indicatorParser,
measureParser
} from './src/parser'
console.log('Testing Risk Catalogue Parser...\n')
// Test 1: List all risks
console.log('1. Testing listAllRisks()...')
try {
const risks = listAllRisks()
console.log(` Found ${risks.length} risks`)
if (risks.length > 0) {
console.log(` First risk: ${risks[0].id} - ${risks[0].title}`)
}
} catch (error) {
console.error(' Error:', error instanceof Error ? error.message : error)
}
// Test 2: Parse a specific risk
console.log('\n2. Testing parseRisk()...')
try {
const risks = listAllRisks()
if (risks.length > 0) {
const risk = parseRisk(risks[0].filePath)
console.log(` Parsed risk: ${risk.metadata.id}`)
console.log(` Title: ${risk.metadata.title}`)
console.log(` Sections: ${Object.keys(risk.sections).join(', ')}`)
} else {
console.log(' No risks found to parse')
}
} catch (error) {
console.error(' Error:', error instanceof Error ? error.message : error)
}
// Test 3: List all indicators
console.log('\n3. Testing listAllIndicators()...')
try {
const indicators = indicatorParser.listAllIndicators()
console.log(` Found ${indicators.length} indicators`)
if (indicators.length > 0) {
console.log(` First indicator: ${indicators[0].id} - ${indicators[0].title}`)
}
} catch (error) {
console.error(' Error:', error instanceof Error ? error.message : error)
}
// Test 4: Parse a specific indicator
console.log('\n4. Testing parseIndicator()...')
try {
const indicators = indicatorParser.listAllIndicators()
if (indicators.length > 0) {
const indicator = indicatorParser.parseIndicator(indicators[0].filePath)
console.log(` Parsed indicator: ${indicator.id}`)
console.log(` Title: ${indicator.title}`)
console.log(` Description length: ${indicator.description.length} chars`)
} else {
console.log(' No indicators found to parse')
}
} catch (error) {
console.error(' Error:', error instanceof Error ? error.message : error)
}
// Test 5: List all measures
console.log('\n5. Testing listAllMeasures()...')
try {
const measures = measureParser.listAllMeasures()
console.log(` Found ${measures.length} measures`)
if (measures.length > 0) {
console.log(` First measure: ${measures[0].id} - ${measures[0].title}`)
}
} catch (error) {
console.error(' Error:', error instanceof Error ? error.message : error)
}
// Test 6: Parse a specific measure
console.log('\n6. Testing parseMeasure()...')
try {
const measures = measureParser.listAllMeasures()
if (measures.length > 0) {
const measure = measureParser.parseMeasure(measures[0].filePath)
console.log(` Parsed measure: ${measure.id}`)
console.log(` Title: ${measure.title}`)
console.log(` Description length: ${measure.description.length} chars`)
} else {
console.log(' No measures found to parse')
}
} catch (error) {
console.error(' Error:', error instanceof Error ? error.message : error)
}
console.log('\nAll tests completed!')