habitica-self-host/test/scoring.mocha.coffee

44 lines
1.5 KiB
CoffeeScript
Raw Normal View History

2012-09-23 19:19:29 +00:00
{expect} = require 'derby/node_modules/racer/test/util'
{BrowserModel: Model} = require 'derby/node_modules/racer/test/util/model'
2012-09-24 01:07:37 +00:00
derby = require 'derby'
# Custom modules
2012-09-23 19:19:29 +00:00
scoring = require '../src/app/scoring'
schema = require '../src/app/schema'
2012-09-24 01:07:37 +00:00
_ = require '../public/js/underscore-min'
2012-09-23 01:04:34 +00:00
describe 'Scoring', ->
model = null
2012-09-23 19:19:29 +00:00
beforeEach ->
2012-09-23 01:04:34 +00:00
model = new Model
2012-09-23 19:19:29 +00:00
model.set '_user', schema.newUserObject()
2012-09-24 01:07:37 +00:00
scoring.setUser model.at('_user')
2012-09-23 19:19:29 +00:00
it 'should set user defaults correctly', ->
2012-09-23 01:04:34 +00:00
user = model.get '_user'
2012-09-23 19:19:29 +00:00
expect(user.stats).to.eql { money: 0, exp: 0, lvl: 1, hp: 50 }
expect(user.items).to.eql { itemsEnabled: false, armor: 0, weapon: 0, rerollsRemaining: 5 }
expect(user.balance).to.eql 2
expect(_.size(user.tasks)).to.eql 9
expect(_.size(user.habitIds)).to.eql 3
expect(_.size(user.dailyIds)).to.eql 3
expect(_.size(user.todoIds)).to.eql 1
expect(_.size(user.completedIds)).to.eql 0
expect(_.size(user.rewardIds)).to.eql 2
2012-09-24 01:07:37 +00:00
it 'should modify damage based on lvl & armor', ->
user = model.at('_user')
[lvl,armor] = [user.get('stats.lvl'), user.get('items.armor')]
expect(lvl).to.eql 1
expect(armor).to.eql 0
uuid = derby.uuid()
model.at('_user.tasks').push {type: 'habit', text: 'Habit', value: 0, up: true, down: true, id: uuid}
task = model.get("_user.tasks")
console.log task
# modified = scoring.score
it 'should always decrease hp with damage, regardless of stats/items'
it 'should always increase exp/gp with gain, regardless of stats/items'