mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-05 12:02:13 +00:00
model returns full user object
This commit is contained in:
parent
656b0891ed
commit
5b67c0fa49
2 changed files with 15 additions and 14 deletions
|
|
@ -12,8 +12,9 @@ casper.on('remote.message'
|
|||
casper.start url, ->
|
||||
casper.test.assertTitle 'HabitRPG | Gamify Your Life', 'Page Title'
|
||||
helpers.getModel (res) ->
|
||||
utils.dump res._user.stats
|
||||
casper.echo 'aaa'
|
||||
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')
|
||||
|
||||
|
||||
# ---------- Run ------------
|
||||
|
|
|
|||
|
|
@ -5,21 +5,21 @@ module.exports = ->
|
|||
casper = require("casper").create
|
||||
clientScripts: 'lib/lodash.min.js'
|
||||
getModel = (cb)->
|
||||
casper.echo 'Getting model...'
|
||||
casper.waitFor(
|
||||
->
|
||||
casper.evaluate ->
|
||||
console.log typeof window.DERBY.app.model.get('_user.stats')
|
||||
typeof window.DERBY.app.model == "object" && typeof window.DERBY.app.model.get('_user.stats') == "object"
|
||||
cb casper.evaluate ->
|
||||
model = window.DERBY.app.model
|
||||
{
|
||||
_userId: model.get('_userId')
|
||||
_user: model.get('_user')
|
||||
_todoList: model.get('_todoList')
|
||||
_dailyList: model.get('_dailyList')
|
||||
_rewardList: model.get('_rewardList')
|
||||
_habitList: model.get('_habitList')
|
||||
}
|
||||
user = window.DERBY.app.model.get('_user')
|
||||
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
|
||||
for k of user
|
||||
userCopy[k] = user[k] #dirty hack to get all fields in the object
|
||||
if check then console.log '...sending model...'
|
||||
check
|
||||
->
|
||||
casper.echo '...model ready...'
|
||||
cb casper.evaluate ->
|
||||
window.userCopy
|
||||
)
|
||||
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue