Skip to content

Commit

Permalink
Fixed jest configuration in package.json so that it actually runs ins…
Browse files Browse the repository at this point in the history
…tead of having security issues (see √=jestjs/jest#6769).

Added first test - simple mock/expectation test to enemyService.test.js
  • Loading branch information
brynachj committed Aug 4, 2018
1 parent a05d1f8 commit aaf8196
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
15 changes: 15 additions & 0 deletions js/src/enemyService.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const underTest = require('./enemyService.js')
var enemyManager = require('./enemyManager.js')
var playerModule = require('./player.js')
var enemyDrawer = require('./enemyDrawer.js')
var collisionDetectionModule = require('./collisionDetection.js')

jest.mock('./enemyManager.js')
jest.mock('./player.js')
jest.mock('./enemyDrawer.js')
jest.mock('./collisionDetection.js')

test('addEnemy calls the enemyManager addEnemy function', () => {
underTest.addEnemy(1, 2)
expect(enemyManager.addEnemy).toHaveBeenCalledWith(1, 2)
})
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"prebundle": "eslint .",
"bundleNoLint": "browserify js/src/main.js -o js/src/bundle.js",
"test": "jest"
},
"jest":{
"verbose": true,
"testURL": "http://localhost/"
}
}

0 comments on commit aaf8196

Please sign in to comment.