Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Add tests for Questionnaire pages
Browse files Browse the repository at this point in the history
  • Loading branch information
brew committed Jun 1, 2017
1 parent 58e7948 commit dd710aa
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ environment:
env:
node: true
browser: true
mocha: true
parserOptions:
sourceType: module
rules:
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
"jsdom": "9.4.1",
"jsdom-global": "2.0.0",
"mocha": "^3.0.0",
"webpack-dev-server": "^1.14.1"
"webpack-dev-server": "^1.14.1",
"zombie": "^5.0.5"
},
"directories": {
"test": "tests"
Expand Down
53 changes: 53 additions & 0 deletions tests/questionnaires.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
const Browser = require('zombie')

describe('User visits questionnaire page', () => {
describe('authenticated', () => {
const browser = new Browser()
browser.proxy = 'http://localhost:3000'

before(done => {
const [basicUserName, basicUserPass] = process.env.QUESTIONNAIRE_AUTH.split(':')
browser.on('authenticate', authentication => {
authentication.username = basicUserName
authentication.password = basicUserPass
})
browser.visit('/questionnaires', done)
})

it('should be successful', () => {
browser.assert.success()
})

it('should have country dropdown', () =>{
browser.assert.element('.country-nav-select')
browser.assert.elements('.country-nav-select option', 12)
})
})

describe('unauthenticated', () => {
const browser = new Browser()
browser.proxy = 'http://localhost:3000'

describe('without credentials', () => {
it('should return status code 401', (done) => {
browser.visit('/questionnaires', () => {
browser.assert.status(401)
done()
})
})
})

describe('wrong credentials', () => {
it('should return status code 401', (done) => {
browser.on('authenticate', authentication => {
authentication.username = 'wronguser'
authentication.password = 'wrongpass'
})
browser.visit('/questionnaires', () => {
browser.assert.status(401)
done()
})
})
})
})
})

0 comments on commit dd710aa

Please sign in to comment.