-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathcodeSnippetSpec.ts
More file actions
44 lines (37 loc) · 1.67 KB
/
Copy pathcodeSnippetSpec.ts
File metadata and controls
44 lines (37 loc) · 1.67 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
import chai = require('chai')
import sinonChai = require('sinon-chai')
const expect = chai.expect
chai.use(sinonChai)
const { getVerdict } = require('../../routes/vulnCodeSnippet')
describe('vulnCodeSnippet', () => {
it('should assert single correctly selected vuln line as correct', () => {
expect(getVerdict([1], [], [1])).to.equal(true)
})
it('should assert multiple correctly selected vuln lines as correct in any order', () => {
expect(getVerdict([1, 2], [], [1, 2])).to.equal(true)
expect(getVerdict([1, 2], [], [2, 1])).to.equal(true)
expect(getVerdict([1, 2, 3], [], [3, 1, 2])).to.equal(true)
})
it('should ignore selected neutral lines during correct assertion', () => {
expect(getVerdict([1, 2], [3, 4], [1, 2, 3])).to.equal(true)
expect(getVerdict([1, 2], [3, 4], [1, 2, 4])).to.equal(true)
expect(getVerdict([1, 2], [3, 4], [1, 2, 3, 4])).to.equal(true)
})
it('should assert missing vuln lines as wrong', () => {
expect(getVerdict([1, 2], [], [1])).to.equal(false)
expect(getVerdict([1, 2], [], [2])).to.equal(false)
expect(getVerdict([1, 2], [3], [2, 3])).to.equal(false)
expect(getVerdict([1, 2], [3], [1, 3])).to.equal(false)
expect(getVerdict([1, 2], [3, 4], [3, 4])).to.equal(false)
})
it('should assert additionally selected lines as wrong', () => {
expect(getVerdict([1, 2], [], [1, 2, 3])).to.equal(false)
expect(getVerdict([1, 2], [3], [1, 2, 3, 4])).to.equal(false)
})
it('should assert lack of selected lines as wrong', () => {
expect(getVerdict([1, 2], [], [])).to.equal(false)
})
it('should assert empty edge case as correct', () => {
expect(getVerdict([], [], [])).to.equal(true)
})
})