Merge branch 'master' of github.com:lefnire/habitrpg

This commit is contained in:
Tyler Renelle 2013-02-17 12:21:16 -05:00
commit 626745bb66
78 changed files with 62 additions and 55 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -1,47 +1,42 @@
helper = new require('./test/casper/helpers')()
casper = helper.casper
utils = helper.utils
url = helper.url
helpers = new require('./test/casper/helpers')()
casper = helpers.casper
utils = helpers.utils
url = helpers.playUrl
casper.start url + '/?play=1'
casper.start url
# ---------- Daily ------------
casper.then ->
helper.reset()
helper.addTasks()
helpers.reset()
helpers.addTasks()
# Gained exp on +daily
casper.then ->
user = helper.userBeforeAfter (-> casper.click '.dailys input[type="checkbox"]')
@test.assertEquals user.before.stats.hp, user.after.stats.hp, '+daily =hp'
@test.assert user.before.stats.exp < user.after.stats.exp, '+daily +exp'
@test.assert user.before.stats.money < user.after.stats.money, '+daily +money'
helpers.modelBeforeAfter (-> casper.click '.dailys input[type="checkbox"]'), (model) ->
casper.test.assertEquals model.before._user.stats.hp, model.after._user.stats.hp, '+daily =hp'
casper.test.assert model.before._user.stats.exp < model.after._user.stats.exp, '+daily +exp'
casper.test.assert model.before._user.stats.gp < model.after._user.stats.gp, '+daily +gp'
# -daily acts as undo
casper.then ->
user = helper.userBeforeAfter (-> casper.click '.dailys input[type="checkbox"]')
@test.assertEquals user.before.stats.hp, user.after.stats.hp, '-daily =hp'
@test.assert user.before.stats.exp > user.after.stats.exp, '-daily -exp'
@test.assert user.before.stats.money > user.after.stats.money, '-daily -money'
helpers.modelBeforeAfter (-> casper.click '.dailys input[type="checkbox"]'), (model) ->
casper.test.assertEquals model.before._user.stats.hp, model.after._user.stats.hp, '-daily =hp'
casper.test.assert model.before._user.stats.exp > model.after._user.stats.exp, '-daily -exp'
casper.test.assert model.before._user.stats.gp > model.after._user.stats.gp, '-daily -gp'
# ---------- Cron ------------
casper.then ->
helpers.reset()
helpers.addTasks()
casper.then ->
helper.reset()
helper.addTasks()
casper.then ->
helper.cronBeforeAfter (beforeAfter) ->
helpers.cronBeforeAfter (model) ->
casper.then ->
#TODO make sure true for all dailies
dailyId = beforeAfter.before.tasks.daily[0].id
# utils.dump
# dailyBefore:user.before.tasks[dailyId].value
# dailyAfter:user.before.tasks[dailyId].value
casper.test.assert beforeAfter.before.user.tasks[dailyId].value < beforeAfter.after.user.tasks[dailyId].value, "daily:cron:daily gained value"
casper.test.assert beforeAfter.before.user.stats.hp < beforeAfter.after.user.stats.hp, 'daily:cron:hp lost value'
#TODO make sure true for all dailies
dailyId = model.before._user.dailyIds[0]
casper.test.assert model.before._user.tasks[dailyId].value < model.after._user.tasks[dailyId].value, "daily:cron:daily gained value"
casper.test.assert model.before._user.stats.hp < model.after._user.stats.hp, 'daily:cron:hp lost value'
# ---------- Run ------------
casper.run ->
@test.renderResults true

View file

@ -2,15 +2,32 @@ utils = require('utils')
module.exports = ->
SYNC_WAIT_TIME = 20
baseUrl = 'http://localhost:3000'
random = Math.random().toString(36).substring(7)
casper = require("casper").create
clientScripts: 'test/includes/lodash.min.js'
getModel = ->
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')
}
{
casper: casper
url: 'http://localhost:3000'
baseUrl: baseUrl
playUrl: baseUrl + '/?play=1'
utils: utils
@ -25,27 +42,20 @@ module.exports = ->
reset: ->
casper.evaluate -> window.DERBY.app.reset()
getModel: ->
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')
}
getModelDelayed: (cb) ->
casper.wait SYNC_WAIT_TIME, ->
cb(getModel())
modelBeforeAfter: (between_cb, done_cb) ->
that = @
model = {before:@getModel()}
casper.then ->
between_cb()
model = {}
@getModelDelayed (before) ->
model.before = before
casper.then ->
model.after = that.getModel()
#utils.dump model
casper.then -> done_cb(model)
between_cb()
that.getModelDelayed (after) ->
model.after = after
casper.then -> done_cb(model)
runCron: ->
casper.evaluate -> window.DERBY.model.set('_user.lastCron', new Date('01/25/2013'))
@ -53,15 +63,17 @@ module.exports = ->
cronBeforeAfter: (cb) ->
that = @
model = {before:@getModel()}
casper.then -> that.runCron()
casper.then ->
casper.wait 1050, -> # user's hp is updated after 1s for animation
model.after = that.getModel()
casper.then ->
casper.test.assertEqual beforeAfter.before.user.id, beforeAfter.after.user.id, 'user id equal after cron'
casper.test.assertEqual beforeAfter.before.user.tasks.length, beforeAfter.after.user.tasks.length, "Didn't lose anything on cron"
cb(beforeAfter)
model = {}
@getModelDelayed (before) ->
model.before = before
casper.then -> that.runCron()
casper.then ->
casper.wait 1050, -> # user's hp is updated after 1s for animation
model.after = getModel()
casper.then ->
casper.test.assertEqual model.before._user.id, model.after._user.id, 'user id equal after cron'
casper.test.assertEqual model.before._user.tasks.length, model.after._user.tasks.length, "Didn't lose anything on cron"
cb(model)
register: ->