forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasterEggSpec.js
37 lines (29 loc) · 1.04 KB
/
easterEggSpec.js
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
/*
* Copyright (c) 2014-2020 Bjoern Kimminich.
* SPDX-License-Identifier: MIT
*/
const sinon = require('sinon')
const chai = require('chai')
const sinonChai = require('sinon-chai')
const expect = chai.expect
chai.use(sinonChai)
describe('easterEgg', () => {
const serveEasterEgg = require('../../routes/easterEgg')
const challenges = require('../../data/datacache').challenges
beforeEach(() => {
this.res = { sendFile: sinon.spy() }
this.req = {}
this.save = () => ({
then () { }
})
})
it('should serve /frontend/dist/frontend/assets/private/threejs-demo.html', () => {
serveEasterEgg()(this.req, this.res)
expect(this.res.sendFile).to.have.been.calledWith(sinon.match(/frontend[/\\]dist[/\\]frontend[/\\]assets[/\\]private[/\\]threejs-demo\.html/))
})
it('should solve "easterEggLevelTwoChallenge"', () => {
challenges.easterEggLevelTwoChallenge = { solved: false, save: this.save }
serveEasterEgg()(this.req, this.res)
expect(challenges.easterEggLevelTwoChallenge.solved).to.equal(true)
})
})