2013-04-01 14:43:26 +00:00
|
|
|
#helpers = new require('./lib/helpers')()
|
|
|
|
|
#casper = helpers.casper
|
|
|
|
|
helpers = casper.helpers
|
2013-04-02 13:47:37 +00:00
|
|
|
eTest = helpers.evalTest
|
|
|
|
|
getModel = helpers.getModel
|
2013-04-01 14:43:26 +00:00
|
|
|
# ---------- Checks if clicking on the buttons changes stats and in right direction ------------
|
|
|
|
|
|
2013-04-02 14:05:36 +00:00
|
|
|
|
2013-04-01 14:43:26 +00:00
|
|
|
casper.start helpers.playUrl, ->
|
2013-04-02 14:05:36 +00:00
|
|
|
test = 'EXP and GP increasing after clicking habits "+"'
|
2013-04-02 13:47:37 +00:00
|
|
|
getModel (err, model) ->
|
2013-04-01 14:43:26 +00:00
|
|
|
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"]'
|
2013-04-02 13:47:37 +00:00
|
|
|
eTest(
|
|
|
|
|
(oldStats)->
|
|
|
|
|
stats = window.DERBY.app.model.get '_user.stats'
|
2013-04-02 14:05:36 +00:00
|
|
|
console.log "Was:" + oldStats.exp + "Is: " + stats.exp
|
|
|
|
|
console.log "Was:" + oldStats.gp + "Is: " + stats.gp
|
2013-04-02 13:47:37 +00:00
|
|
|
(stats.exp > oldStats.exp && stats.gp > oldStats.gp)
|
2013-04-02 14:05:36 +00:00
|
|
|
test
|
2013-04-02 13:47:37 +00:00
|
|
|
model.user.stats
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2013-04-02 14:05:36 +00:00
|
|
|
casper.then ->
|
|
|
|
|
test = 'HP decreasing after clicking habits "-"'
|
|
|
|
|
getModel (err, model) ->
|
|
|
|
|
casper.click '.habits a[data-direction="down"]'
|
|
|
|
|
eTest(
|
|
|
|
|
(oldStats)->
|
|
|
|
|
stats = window.DERBY.app.model.get '_user.stats'
|
|
|
|
|
console.log "Was:" + oldStats.hp + "Is: " + stats.hp
|
|
|
|
|
(stats.hp < oldStats.hp)
|
|
|
|
|
test
|
|
|
|
|
model.user.stats
|
|
|
|
|
)
|
2013-04-01 14:43:26 +00:00
|
|
|
|
2013-04-02 14:05:36 +00:00
|
|
|
casper.then ->
|
|
|
|
|
test = 'EXP and GP increasing after clicking .todo.uncompleted'
|
|
|
|
|
getModel (err, model) ->
|
|
|
|
|
casper.click '.task.todo.uncompleted input[type=checkbox]'
|
|
|
|
|
eTest(
|
|
|
|
|
(oldStats)->
|
|
|
|
|
stats = window.DERBY.app.model.get '_user.stats'
|
|
|
|
|
console.log "Was:" + oldStats.exp + "Is: " + stats.exp
|
|
|
|
|
console.log "Was:" + oldStats.gp + "Is: " + stats.gp
|
|
|
|
|
(stats.exp > oldStats.exp && stats.gp > oldStats.gp)
|
|
|
|
|
test
|
|
|
|
|
model.user.stats
|
|
|
|
|
)
|
2013-04-01 14:43:26 +00:00
|
|
|
|
|
|
|
|
casper.then ->
|
2013-04-02 14:05:36 +00:00
|
|
|
test = 'EXP and GP decreasing after clicking .todo.completed'
|
|
|
|
|
getModel (err, model) ->
|
|
|
|
|
casper.click '.task.todo.completed input[type=checkbox]'
|
|
|
|
|
eTest(
|
|
|
|
|
(oldStats)->
|
|
|
|
|
stats = window.DERBY.app.model.get '_user.stats'
|
|
|
|
|
console.log "Was:" + oldStats.exp + "Is: " + stats.exp
|
|
|
|
|
console.log "Was:" + oldStats.gp + "Is: " + stats.gp
|
|
|
|
|
(stats.exp < oldStats.exp && stats.gp < oldStats.gp)
|
|
|
|
|
test
|
|
|
|
|
model.user.stats
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
casper.then ->
|
|
|
|
|
test = 'EXP and GP increasing after clicking .daily.uncompleted'
|
2013-04-02 13:47:37 +00:00
|
|
|
getModel (err, model) ->
|
2013-04-01 14:43:26 +00:00
|
|
|
casper.click '.task.daily.uncompleted input[type=checkbox]'
|
2013-04-02 13:47:37 +00:00
|
|
|
eTest(
|
2013-04-02 14:05:36 +00:00
|
|
|
(oldStats)->
|
|
|
|
|
stats = window.DERBY.app.model.get '_user.stats'
|
|
|
|
|
console.log "Was:" + oldStats.exp + "Is: " + stats.exp
|
|
|
|
|
console.log "Was:" + oldStats.gp + "Is: " + stats.gp
|
|
|
|
|
(stats.exp > oldStats.exp && stats.gp > oldStats.gp)
|
|
|
|
|
test
|
|
|
|
|
model.user.stats
|
|
|
|
|
)
|
2013-04-02 13:47:37 +00:00
|
|
|
|
2013-04-02 14:05:36 +00:00
|
|
|
casper.then ->
|
|
|
|
|
test = 'EXP and GP decreasing after clicking .daily.completed'
|
|
|
|
|
getModel (err, model) ->
|
|
|
|
|
casper.click '.task.daily.completed input[type=checkbox]'
|
|
|
|
|
eTest(
|
|
|
|
|
(oldStats)->
|
|
|
|
|
stats = window.DERBY.app.model.get '_user.stats'
|
|
|
|
|
console.log "Was:" + oldStats.exp + "Is: " + stats.exp
|
|
|
|
|
console.log "Was:" + oldStats.gp + "Is: " + stats.gp
|
|
|
|
|
(stats.exp < oldStats.exp && stats.gp < oldStats.gp)
|
|
|
|
|
test
|
|
|
|
|
model.user.stats
|
2013-04-02 13:47:37 +00:00
|
|
|
)
|
2013-04-01 14:43:26 +00:00
|
|
|
|
2013-04-02 14:05:36 +00:00
|
|
|
|
2013-04-01 14:43:26 +00:00
|
|
|
# ---------- finish tests ------------
|
|
|
|
|
casper.then ->
|
|
|
|
|
casper.test.done()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ---------- Run ------------
|
|
|
|
|
casper.run ->
|
|
|
|
|
casper.test.renderResults true
|