-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.test.js
More file actions
34 lines (27 loc) · 1.22 KB
/
index.test.js
File metadata and controls
34 lines (27 loc) · 1.22 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
import { describe, it, expect } from '@jest/globals'
import { iterateFiles, deepFlatten } from './index.mjs'
import Signatures from './signatures/index.mjs'
import path from 'node:path'
const projectRoot = process.cwd()
const samplesDir = path.join(projectRoot, 'samples')
describe('Signature Integration Test', () => {
it('should trigger all defined signatures when scanning the samples directory', async () => {
const scanOptions = { json: true }
expect(Array.isArray(Signatures)).toBe(true)
const allSignatureNames = new Set(Signatures.map(sig => sig.name))
expect(allSignatureNames.size).toBeGreaterThan(0)
const rawResults = await iterateFiles(samplesDir, scanOptions)
const flatResults = deepFlatten(rawResults).filter(r => r && typeof r === 'object')
const triggeredSignatureNames = new Set(
flatResults
.filter(result => result.triggered)
.map(result => result.name)
)
const missingSignatures = []
for (const name of allSignatureNames) {
if (!triggeredSignatureNames.has(name)) missingSignatures.push(name)
}
if (missingSignatures.length > 0) console.error('Missing Signatures:', missingSignatures)
expect(missingSignatures).toEqual([])
}, 60000)
})