using eval tests2

This commit is contained in:
yangit
2013-04-02 21:47:37 +08:00
parent c9112feaf7
commit 8a6fede4fe
2 changed files with 29 additions and 17 deletions
+24 -13
View File
@@ -1,17 +1,27 @@
#helpers = new require('./lib/helpers')()
#casper = helpers.casper
helpers = casper.helpers
eTest = helpers.evalTest
getModel = helpers.getModel
# ---------- Checks if clicking on the buttons changes stats and in right direction ------------
#click .habits "+" and see if GP and XP are going up.
casper.start helpers.playUrl, ->
helpers.getModel (err, model) ->
getModel (err, model) ->
casper.test.assertEquals(typeof model.user.stats.exp, "number", 'XP is number')
casper.test.assertEquals(model.user.stats.exp, 0, 'XP == 0')
casper.click '.habits a[data-direction="up"]'
helpers.getModel (err, newModel) ->
casper.test.assert(newModel.user.stats.exp > model.user.stats.exp, 'XP has increased after clicking habits "+"')
casper.test.assert(newModel.user.stats.gp > model.user.stats.gp, 'GP has increased after clicking habits "+"')
eTest(
(oldStats)->
stats = window.DERBY.app.model.get '_user.stats'
console.log "Is: " + stats.exp + " Was:" + oldStats.exp
console.log "Is: " + stats.gp + " Was:" + oldStats.gp
(stats.exp > oldStats.exp && stats.gp > oldStats.gp)
'EXP and GP has increased after clicking habits "+"'
model.user.stats
)
#
##click .habits "-" and see if HP is going down
#casper.then ->
@@ -56,15 +66,16 @@ casper.start helpers.playUrl, ->
#click .daily.uncompleted and see if GP and EXP are going up.
casper.then ->
helpers.getModel (err, model) ->
getModel (err, model) ->
casper.click '.task.daily.uncompleted input[type=checkbox]'
helpers.evalTest(
-> #check function
casper.evaluate ((exp)->
console.log "Is: " + window.DERBY.app.model.get('_user.stats.exp') + " Was:" + exp
(window.DERBY.app.model.get('_user.stats.exp') > exp)), model.user.stats.exp
'EXP has increased after checking uncompleted daliy'
)
eTest(
(exp)->
console.log "Is: " + window.DERBY.app.model.get('_user.stats.exp') + " Was:" + exp
(window.DERBY.app.model.get('_user.stats.exp') > exp)
'EXP has increased after checking uncompleted daliy'
model.user.stats.exp
)
# ---------- finish tests ------------
casper.then ->
+5 -4
View File
@@ -1,8 +1,8 @@
utils = require('utils')
#enable this to get remote console output, useful for debug.
casper.on "remote.message", (msg)->
casper.echo "Remote console: " + msg
#casper.on "remote.message", (msg)->
# casper.echo "Remote console: " + msg
casper.helpers = (->
baseUrl = 'http://localhost:3000'
@@ -25,9 +25,10 @@ casper.helpers = (->
{user: window.userCopy}
cb null, model
)
evalTest = (check, text) ->
evalTest = (check, text, variables) ->
casper.waitFor(
check
-> #check function
casper.evaluate check, variables
-> #run this if check passed
casper.test.assert(true, text)
-> #run this if timeout