Skip to content

Commit

Permalink
[bot] migrate files
Browse files Browse the repository at this point in the history
<!-- grit:execution_id:60e7059a-0455-476b-ac9b-b1142e9c77cc -->
  • Loading branch information
grit-app[bot] committed Dec 19, 2023
1 parent 90645eb commit ffc54e8
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 200 deletions.
4 changes: 2 additions & 2 deletions test/server/angularSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('angular', () => {
serveAngularClient()(req, res, next)

expect(res.sendFile).to.have.not.been.calledWith(sinon.match.any)
expect(next).to.have.been.calledWith(sinon.match.instanceOf(Error))
expect(next).to.have.been.calledWith(sinon.match.toBeInstanceOf(Error))
})

it('should raise error for /rest endpoint URL', () => {
Expand All @@ -44,6 +44,6 @@ describe('angular', () => {
serveAngularClient()(req, res, next)

expect(res.sendFile).to.have.not.been.calledWith(sinon.match.any)
expect(next).to.have.been.calledWith(sinon.match.instanceOf(Error))
expect(next).to.have.been.calledWith(sinon.match.toBeInstanceOf(Error))
})
})
10 changes: 5 additions & 5 deletions test/server/b2bOrderSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('b2bOrder', () => {

createB2bOrder()(req, res, next)

expect(challenges.rceChallenge.solved).to.equal(true)
expect(challenges.rceChallenge.solved).toBe(true)
})

xit('timeout after 2 seconds solves "rceOccupyChallenge"', () => { // FIXME Started failing on Linux regularly
Expand All @@ -43,7 +43,7 @@ describe('b2bOrder', () => {

createB2bOrder()(req, res, next)

expect(challenges.rceOccupyChallenge.solved).to.equal(true)
expect(challenges.rceOccupyChallenge.solved).toBe(true)
}, 3000)

it('deserializing JSON as documented in Swagger should not solve "rceChallenge"', () => {
Expand All @@ -53,7 +53,7 @@ describe('b2bOrder', () => {

createB2bOrder()(req, res, next)

expect(challenges.rceChallenge.solved).to.equal(false)
expect(challenges.rceChallenge.solved).toBe(false)
})

it('deserializing arbitrary JSON should not solve "rceChallenge"', () => {
Expand All @@ -62,7 +62,7 @@ describe('b2bOrder', () => {
req.body.orderLinesData = '{"hello": "world", "foo": 42, "bar": [false, true]}'

createB2bOrder()(req, res, next)
expect(challenges.rceChallenge.solved).to.equal(false)
expect(challenges.rceChallenge.solved).toBe(false)
})

it('deserializing broken JSON should not solve "rceChallenge"', () => {
Expand All @@ -72,6 +72,6 @@ describe('b2bOrder', () => {

createB2bOrder()(req, res, next)

expect(challenges.rceChallenge.solved).to.equal(false)
expect(challenges.rceChallenge.solved).toBe(false)
})
})
2 changes: 1 addition & 1 deletion test/server/blueprintSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('blueprint', () => {
}
const properties = Object.values(exifData.image)
product.exifForBlueprintChallenge.forEach((property: string) => {
expect(properties).to.include(property)
expect(properties).toContain(property)
})
})
}
Expand Down
4 changes: 2 additions & 2 deletions test/server/botUtilsSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('botUtils', () => {

describe('testFunction', () => {
it('returns static test response', () => {
expect(botUtils.testFunction()).to.deep.equal({
expect(botUtils.testFunction()).toEqual({
action: 'response',
body: '3be2e438b7f3d04c89d7749f727bb3bd'
})
Expand All @@ -21,7 +21,7 @@ describe('botUtils', () => {

describe('couponCode', () => {
it('response contains a valid 10% coupon code for current date', () => {
expect(botUtils.couponCode()).to.deep.equal({
expect(botUtils.couponCode()).toEqual({
action: 'response',
body: `Oooookay, if you promise to stop nagging me here's a 10% coupon code for you: ${security.generateCoupon(10, new Date())}`
})
Expand Down
2 changes: 1 addition & 1 deletion test/server/challengeCountryMappingSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('challengeCountryMapping', () => {
for (const key of Object.keys(countryCodeCounts)) {
const count = countryCodeCounts[key]

expect(count, `Country "${key}" is used for multiple country mappings.`).to.equal(1)
expect(count, `Country "${key}" is used for multiple country mappings.`).toBe(1)
}
})
})
2 changes: 1 addition & 1 deletion test/server/challengeTutorialSequenceSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('challengeTutorialSequence', () => {
for (const order of Object.keys(tutorialOrderCounts)) {
const count = tutorialOrderCounts[order]

expect(count, `Tutorial order "${order}" is used for multiple challenges.`).to.equal(1)
expect(count, `Tutorial order "${order}" is used for multiple challenges.`).toBe(1)
}
})
})
10 changes: 5 additions & 5 deletions test/server/chatBotValidationSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('chatBotValidation', () => {
]
}

expect(checkIntentWithFunctionHandlerExists(trainingData, 'queries.test', 'testHandler')).to.equal(true)
expect(checkIntentWithFunctionHandlerExists(trainingData, 'queries.test', 'testHandler')).toBe(true)
})

it('should fail if the training data lacks the expected intent', () => {
Expand All @@ -40,7 +40,7 @@ describe('chatBotValidation', () => {
]
}

expect(checkIntentWithFunctionHandlerExists(trainingData, 'queries.test')).to.equal(false)
expect(checkIntentWithFunctionHandlerExists(trainingData, 'queries.test')).toBe(false)
})

it('should fail if the training data lacks the expected handler for the given intent', () => {
Expand All @@ -58,15 +58,15 @@ describe('chatBotValidation', () => {
]
}

expect(checkIntentWithFunctionHandlerExists(trainingData, 'queries.test', 'testHandler')).to.equal(false)
expect(checkIntentWithFunctionHandlerExists(trainingData, 'queries.test', 'testHandler')).toBe(false)
})
})

it('should accept the default chatbot training data', () => {
expect(validateChatBot(require('../../data/static/botDefaultTrainingData.json'))).to.equal(true)
expect(validateChatBot(require('../../data/static/botDefaultTrainingData.json'))).toBe(true)
})

it('should fail if the chatbot training data is empty', () => {
expect(validateChatBot({ data: [] }, false)).to.equal(false)
expect(validateChatBot({ data: [] }, false)).toBe(false)
})
})
32 changes: 16 additions & 16 deletions test/server/codeSnippetSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ const { getVerdict } = require('../../routes/vulnCodeSnippet')

describe('vulnCodeSnippet', () => {
it('should assert single correctly selected vuln line as correct', () => {
expect(getVerdict([1], [], [1])).to.equal(true)
expect(getVerdict([1], [], [1])).toBe(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)
expect(getVerdict([1, 2], [], [1, 2])).toBe(true)
expect(getVerdict([1, 2], [], [2, 1])).toBe(true)
expect(getVerdict([1, 2, 3], [], [3, 1, 2])).toBe(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)
expect(getVerdict([1, 2], [3, 4], [1, 2, 3])).toBe(true)
expect(getVerdict([1, 2], [3, 4], [1, 2, 4])).toBe(true)
expect(getVerdict([1, 2], [3, 4], [1, 2, 3, 4])).toBe(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)
expect(getVerdict([1, 2], [], [1])).toBe(false)
expect(getVerdict([1, 2], [], [2])).toBe(false)
expect(getVerdict([1, 2], [3], [2, 3])).toBe(false)
expect(getVerdict([1, 2], [3], [1, 3])).toBe(false)
expect(getVerdict([1, 2], [3, 4], [3, 4])).toBe(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)
expect(getVerdict([1, 2], [], [1, 2, 3])).toBe(false)
expect(getVerdict([1, 2], [3], [1, 2, 3, 4])).toBe(false)
})

it('should assert lack of selected lines as wrong', () => {
expect(getVerdict([1, 2], [], [])).to.equal(false)
expect(getVerdict([1, 2], [], [])).toBe(false)
})

it('should assert empty edge case as correct', () => {
expect(getVerdict([], [], [])).to.equal(true)
expect(getVerdict([], [], [])).toBe(true)
})
})
6 changes: 3 additions & 3 deletions test/server/codingChallengeFixesSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import { retrieveChallengesWithCodeSnippet } from '../../routes/vulnCodeSnippet'
import { readFixes } from '../../routes/vulnCodeFixes'
import chai = require('chai')
import fs from 'graceful-fs'
import chai = require('chai')
const sinonChai = require('sinon-chai')
const expect = chai.expect
chai.use(sinonChai)
Expand All @@ -20,7 +20,7 @@ describe('codingChallengeFixes', () => {
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)
expect(fixes.correct, `Coding challenge ${challenge} does not have a correct fix file`).toBeGreaterThan(-1)
}
})

Expand All @@ -33,7 +33,7 @@ describe('codingChallengeFixes', () => {

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)
expect(fs.existsSync('./data/static/codefixes/' + challenge + '.info.yml'), `Coding challenge ${challenge} does not have an info YAML file`).toBe(true)
}
})
})
Loading

0 comments on commit ffc54e8

Please sign in to comment.