mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Added jasmine spec reporter and tests for anonymous name collisions.
This commit is contained in:
parent
834c27bbd7
commit
0cd5d0f4af
3 changed files with 53 additions and 3 deletions
|
@ -46,7 +46,7 @@
|
|||
"mongoose": "3.8.x",
|
||||
"mongoose-text-search": "~0.0.2",
|
||||
"request": "2.12.x",
|
||||
"tv4": "1.0.x",
|
||||
"tv4": "~1.0.16",
|
||||
"lodash": "~2.0.0",
|
||||
"underscore.string": "2.3.x",
|
||||
"async": "0.2.x",
|
||||
|
@ -92,7 +92,8 @@
|
|||
"karma-phantomjs-launcher": "~0.1.1",
|
||||
"karma": "~0.10.9",
|
||||
"karma-coverage": "~0.1.4",
|
||||
"compressible": "~1.0.1"
|
||||
"compressible": "~1.0.1",
|
||||
"jasmine-spec-reporter":"~0.3.0"
|
||||
},
|
||||
"license": "MIT for the code, and CC-BY for the art and music",
|
||||
"private": true,
|
||||
|
|
|
@ -3,7 +3,12 @@
|
|||
|
||||
console.log 'IT BEGINS'
|
||||
|
||||
|
||||
require('jasmine-spec-reporter')
|
||||
jasmine.getEnv().reporter.subReporters_ = []
|
||||
jasmine.getEnv().addReporter(new jasmine.SpecReporter({
|
||||
displaySuccessfulSpec: true,
|
||||
displayFailedSpec: true
|
||||
}))
|
||||
GLOBAL._ = require('lodash')
|
||||
_.str = require('underscore.string')
|
||||
_.mixin(_.str.exports())
|
||||
|
|
|
@ -44,6 +44,20 @@ describe 'User.updateMailChimp', ->
|
|||
|
||||
describe 'POST /db/user', ->
|
||||
|
||||
createAnonNameUser = (done)->
|
||||
request.post getURL('/auth/logout'), ->
|
||||
request.get getURL('/auth/whoami'), ->
|
||||
req = request.post(getURL('/db/user'), (err, response) ->
|
||||
expect(response.statusCode).toBe(200)
|
||||
request.get getURL('/auth/whoami'), (request, response, body) ->
|
||||
res = JSON.parse(response.body)
|
||||
expect(res.anonymous).toBeTruthy()
|
||||
expect(res.name).toEqual('Jim')
|
||||
done()
|
||||
)
|
||||
form = req.form()
|
||||
form.append('name', 'Jim')
|
||||
|
||||
it 'preparing test : clears the db first', (done) ->
|
||||
clearModels [User], (err) ->
|
||||
throw err if err
|
||||
|
@ -90,6 +104,36 @@ describe 'POST /db/user', ->
|
|||
expect(user.passwordHash).toBeUndefined()
|
||||
done()
|
||||
|
||||
it 'should allow setting anonymous user name', (done) ->
|
||||
createAnonNameUser(done)
|
||||
|
||||
it 'should allow multiple anonymous users with same name', (done) ->
|
||||
createAnonNameUser(done)
|
||||
|
||||
|
||||
it 'should not allow setting existing user name to anonymous user', (done) ->
|
||||
|
||||
createAnonUser = ->
|
||||
request.post getURL('/auth/logout'), ->
|
||||
request.get getURL('/auth/whoami'), ->
|
||||
req = request.post(getURL('/db/user'), (err, response) ->
|
||||
expect(response.statusCode).toBe(409)
|
||||
done()
|
||||
)
|
||||
form = req.form()
|
||||
form.append('name', 'Jim')
|
||||
|
||||
req = request.post(getURL('/db/user'), (err,response,body) ->
|
||||
expect(response.statusCode).toBe(200)
|
||||
request.get getURL('/auth/whoami'), (request, response, body) ->
|
||||
res = JSON.parse(response.body)
|
||||
expect(res.anonymous).toBeFalsy()
|
||||
createAnonUser()
|
||||
)
|
||||
form = req.form()
|
||||
form.append('email', 'new@user.com')
|
||||
form.append('password', 'new')
|
||||
|
||||
|
||||
describe 'PUT /db/user', ->
|
||||
|
||||
|
|
Loading…
Reference in a new issue