fix up some tests
This commit is contained in:
+34
-17
@@ -3,6 +3,9 @@ utils = require('utils')
|
||||
casper = require("casper").create
|
||||
clientScripts: 'test/includes/lodash.min.js'
|
||||
|
||||
# ---------- Util Functions ------------
|
||||
getUser = () -> casper.evaluate -> window.DERBY.app.model.get('_user')
|
||||
|
||||
# ---------- Init ------------
|
||||
|
||||
casper.start url, ->
|
||||
@@ -17,9 +20,37 @@ casper.then ->
|
||||
casper.fill "form#new-#{type}", {'new-task': "#{type}-#{num}"} # why can't I use true here?
|
||||
casper.click "form#new-#{type} input[type=submit]"
|
||||
|
||||
# ---------- Cron ------------
|
||||
getUser = () -> casper.evaluate -> window.DERBY.app.model.get('_user')
|
||||
# ---------- Habit ------------
|
||||
casper.then ->
|
||||
userBefore = getUser()
|
||||
@click '.habits a[data-direction="down"]'
|
||||
userAfter = getUser()
|
||||
@test.assert userBefore.stats.hp > userAfter.stats.hp, '-habit: -hp'
|
||||
@test.assert userBefore.stats.exp == userAfter.stats.exp, '-habit: =exp'
|
||||
|
||||
@then ->
|
||||
useBefore = getUser()
|
||||
@click '.habits a[data-direction="up"]'
|
||||
userAfter = getUser()
|
||||
@test.assert userBefore.stats.exp < userAfter.stats.exp, '+habit: +exp'
|
||||
@test.assert userBefore.stats.hp == userAfter.stats.hp, '+habit: =hp'
|
||||
|
||||
# Test Death
|
||||
casper.then ->
|
||||
@repeat 50, ->
|
||||
@click '.habits a[data-direction="down"]'
|
||||
|
||||
@then ->
|
||||
userStats = @evaluate ->
|
||||
window.DERBY.app.model.get('_user.stats')
|
||||
utils.dump userStats
|
||||
|
||||
@test.assert(@visible('#dead-modal'), 'Revive Modal Visible')
|
||||
@test.assert(userStats.hp == 0, 'User HP: 0')
|
||||
@test.assert(userStats.lvl == 0, 'User Lvl: 0')
|
||||
@test.assert(userStats.money == 0, 'User GP: 0')
|
||||
|
||||
# ---------- Cron ------------
|
||||
casper.then ->
|
||||
|
||||
tasksBefore = @evaluate ->
|
||||
@@ -45,21 +76,7 @@ casper.then ->
|
||||
@test.assert tasksBefore.todos[0].value < tasksAfter.todos[0].value, "Todo gained value on cron"
|
||||
@test.assert user.stats.hp < 50, 'User lost HP on cron'
|
||||
|
||||
# ---------- User Death ------------
|
||||
casper.then ->
|
||||
@repeat 55, ->
|
||||
@click '.habits a[data-direction="down"]'
|
||||
|
||||
casper.then ->
|
||||
userStats = @evaluate ->
|
||||
window.DERBY.app.model.get('_user.stats')
|
||||
utils.dump userStats
|
||||
|
||||
@test.assert(@visible('#dead-modal'), 'Revive Modal Visible')
|
||||
@test.assert(userStats.hp == 0, 'User HP: 0')
|
||||
@test.assert(userStats.lvl == 0, 'User Lvl: 0')
|
||||
@test.assert(userStats.money == 0, 'User GP: 0')
|
||||
|
||||
|
||||
# ---------- Misc Pages ------------
|
||||
|
||||
casper.thenOpen "#{url}/terms", ->
|
||||
|
||||
Reference in New Issue
Block a user