From db8723f0d2ae28e3448ea812b0e4e4d3368931c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Jureti=C4=87?= Date: Sat, 28 Sep 2013 18:36:23 -0300 Subject: [PATCH] add tests for store operations --- tests/algos.mocha.coffee | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/algos.mocha.coffee b/tests/algos.mocha.coffee index 958c1dd1b4..ce9c9e25c6 100644 --- a/tests/algos.mocha.coffee +++ b/tests/algos.mocha.coffee @@ -83,6 +83,33 @@ describe 'User', -> expectStrings(user.tags[1], ['name','id']) expectStrings(user.tags[2], ['name','id']) + describe 'store', -> + it 'recovers hp buying potions', -> + user = helpers.newUser() + user.stats.hp = 30 + user.stats.gp = 50 + expect(items.buyItem user, 'potion').to.be true + expect(user.stats.hp).to.eql 45 + expect(user.stats.gp).to.eql 25 + + expect(items.buyItem user, 'potion').to.be true + expect(user.stats.hp).to.eql 50 # don't exceed max hp + expect(user.stats.gp).to.eql 0 + + it 'buys equipment', -> + user = helpers.newUser() + user.stats.gp = 31 + expect(items.buyItem user, 'armor').to.be true + expect(user.items.armor).to.eql 1 + expect(user.stats.gp).to.eql 1 + + it 'do not buy equipment without enough money', -> + user = helpers.newUser() + user.stats.gp = 1 + expect(items.buyItem user, 'armor').to.be false + expect(user.items.armor).to.eql 0 + expect(user.stats.gp).to.eql 1 + describe 'Simple Scoring', -> it 'Habits : Up', ->