Skip to content

Commit

Permalink
Merge pull request #1 from NotGonnaGitUs/GemsRefundTests
Browse files Browse the repository at this point in the history
Test for prize challenge creation and refund
  • Loading branch information
NotGonnaGitUs committed May 4, 2015
2 parents 4085ed5 + 9a3c383 commit ddd2ef0
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/api.mocha.coffee
Expand Up @@ -479,6 +479,35 @@ describe "API", ->
cb()
], done

it "User creates a challenge with prize, deletes it, gets refund", (done) ->
User.findByIdAndUpdate _id,
$set:
"balance": 8
, (err, user) ->
expect(err).to.not.be.ok()
request.post(baseURL + "/challenges").send(
group: group._id
dailys: []
todos: []
rewards: []
habits: []
prize: 10
).end (res) ->
expect(res.body.prize).to.be 10
async.parallel [
(cb) ->
User.findById _id, cb
(cb) ->
Challenge.findById res.body._id, cb
], (err, results) ->
_user = results[0]
challenge = results[1]
expect(_user.balance).to.be 5.5
request.del(baseURL + "/challenges/" + challenge._id).end (res) ->
User.findById _id, (err, user) ->
expect(user.balance).to.be 8
done()

describe "Quests", ->
party = undefined
participating = []
Expand Down

0 comments on commit ddd2ef0

Please sign in to comment.