forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathcodingChallengeFixesSpec.ts
39 lines (34 loc) · 1.46 KB
/
codingChallengeFixesSpec.ts
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
/*
* Copyright (c) 2014-2022 Bjoern Kimminich & the OWASP Juice Shop contributors.
* SPDX-License-Identifier: MIT
*/
import { retrieveChallengesWithCodeSnippet } from '../../routes/vulnCodeSnippet'
import { readFixes } from '../../routes/vulnCodeFixes'
import chai = require('chai')
import fs from 'graceful-fs'
const sinonChai = require('sinon-chai')
const expect = chai.expect
chai.use(sinonChai)
describe('codingChallengeFixes', () => {
let codingChallenges: string[]
before(async () => {
codingChallenges = await retrieveChallengesWithCodeSnippet()
})
it('should have a correct fix for each coding challenge', async () => {
for (const challenge of codingChallenges) {
const fixes = readFixes(challenge)
expect(fixes.correct, `Coding challenge ${challenge} does not have a correct fix file`).to.be.greaterThan(-1)
}
})
it('should have a total of three or more fix options for each coding challenge', async () => {
for (const challenge of codingChallenges) {
const fixes = readFixes(challenge)
expect(fixes.fixes.length, `Coding challenge ${challenge} does not have enough fix option files`).to.be.greaterThanOrEqual(3)
}
})
it('should have an info YAML file for each coding challenge', async () => {
for (const challenge of codingChallenges) {
expect(fs.existsSync('./data/static/codefixes/' + challenge + '.info.yml'), `Coding challenge ${challenge} does not have an info YAML file`).to.equal(true)
}
})
})