-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.test.ts
More file actions
41 lines (35 loc) · 1.33 KB
/
main.test.ts
File metadata and controls
41 lines (35 loc) · 1.33 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
describe('main', () => {
it('placeholder test', () => {
// This is a placeholder test to prevent Jest from failing
// TODO: Add proper unit tests for the main module
expect(true).toBe(true)
})
describe('CWE ID normalization', () => {
const codeQlCweTagPrefix = 'external/cwe/cwe-'
function normalizeCweId(tag: string): string {
const cweId = tag.replace(codeQlCweTagPrefix, '')
const normalizedId = String(parseInt(cweId, 10))
return normalizedId
}
it('should handle CWE IDs with leading zeros', () => {
// Test that cwe-099 maps to 99
const normalizedId = normalizeCweId('external/cwe/cwe-099')
expect(normalizedId).toBe('99')
})
it('should handle CWE IDs without leading zeros', () => {
// Test that cwe-89 maps to 89
const normalizedId = normalizeCweId('external/cwe/cwe-89')
expect(normalizedId).toBe('89')
})
it('should handle CWE IDs with multiple leading zeros', () => {
// Test that cwe-020 maps to 20
const normalizedId = normalizeCweId('external/cwe/cwe-020')
expect(normalizedId).toBe('20')
})
it('should return NaN for non-numeric CWE IDs', () => {
// Test that invalid CWE IDs return NaN
const normalizedId = normalizeCweId('external/cwe/cwe-abc')
expect(normalizedId).toBe('NaN')
})
})
})