mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-31 15:09:32 +00:00
Test if EXP affected by clicking the "habits-up" button.
This commit is contained in:
parent
5b67c0fa49
commit
4a1623c139
2 changed files with 23 additions and 16 deletions
|
|
@ -9,13 +9,16 @@ casper.on('remote.message'
|
|||
)
|
||||
|
||||
# ---------- Basic Test ------------
|
||||
casper.start url, ->
|
||||
casper.test.assertTitle 'HabitRPG | Gamify Your Life', 'Page Title'
|
||||
helpers.getModel (res) ->
|
||||
casper.echo '...model received.'
|
||||
casper.test.assertEquals(typeof res.stats.exp,"number",'experience is number')
|
||||
casper.test.assertEquals(typeof res.stats.exp,0,'experience == 0')
|
||||
|
||||
casper.start url, ->
|
||||
helpers.getModel (model) ->
|
||||
casper.test.assertEquals(typeof model.user.stats.exp, "number", 'exp is number')
|
||||
casper.test.assertEquals(model.user.stats.exp, 0, 'exp == 0')
|
||||
casper.echo 'Clicking...'
|
||||
casper.click '.habits a[data-direction="up"]'
|
||||
casper.echo '...clicked'
|
||||
helpers.getModel (model) ->
|
||||
casper.test.assertEquals(model.user.stats.exp, 7.5, 'exp == 7.5')
|
||||
|
||||
|
||||
# ---------- Run ------------
|
||||
casper.run ->
|
||||
|
|
|
|||
|
|
@ -5,21 +5,25 @@ module.exports = ->
|
|||
casper = require("casper").create
|
||||
clientScripts: 'lib/lodash.min.js'
|
||||
getModel = (cb)->
|
||||
casper.echo 'Getting model...'
|
||||
casper.echo 'Loading model...'
|
||||
casper.waitFor(
|
||||
->
|
||||
-> #check function
|
||||
casper.evaluate ->
|
||||
user = window.DERBY.app.model.get('_user')
|
||||
#wait till all fields get ready
|
||||
check = (typeof user == "object" && typeof user.stats == "object" && typeof user.stats.exp == 'number')
|
||||
window.userCopy = userCopy = {} #assign to the window so we can access it later
|
||||
#assign to the window so we can access it later
|
||||
window.userCopy = userCopy = {}
|
||||
#dirty hack to get all fields in the object
|
||||
for k of user
|
||||
userCopy[k] = user[k] #dirty hack to get all fields in the object
|
||||
if check then console.log '...sending model...'
|
||||
userCopy[k] = user[k]
|
||||
check
|
||||
->
|
||||
casper.echo '...model ready...'
|
||||
cb casper.evaluate ->
|
||||
window.userCopy
|
||||
-> #run this if check passed
|
||||
model = casper.evaluate ->
|
||||
{user: window.userCopy}
|
||||
casper.echo '...model loaded'
|
||||
utils.dump model.user.stats
|
||||
cb model
|
||||
)
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue