model returns full user object

This commit is contained in:
Yangit 2013-03-22 00:36:14 +08:00
parent 656b0891ed
commit 5b67c0fa49
2 changed files with 15 additions and 14 deletions

View file

@ -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 ------------

View file

@ -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
)
{