From b9abc31edbf7e191947fbcd899359efea4b4857b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Jureti=C4=87?= Date: Sat, 23 Nov 2013 23:57:16 -0300 Subject: [PATCH] added test for countPets --- tests/algos.mocha.coffee | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/algos.mocha.coffee b/tests/algos.mocha.coffee index fc2092810b..ee43d60e24 100644 --- a/tests/algos.mocha.coffee +++ b/tests/algos.mocha.coffee @@ -416,3 +416,16 @@ describe 'Helper', -> expect(helpers.startOfDay({now: new Date(2013, 0, 1, 0)}).format('YYYY-MM-DD HH:mm')).to.eql '2013-01-01 00:00' expect(helpers.startOfDay({now: new Date(2013, 0, 1, 5)}).format('YYYY-MM-DD HH:mm')).to.eql '2013-01-01 00:00' expect(helpers.startOfDay({now: new Date(2013, 0, 1, 23, 59, 59)}).format('YYYY-MM-DD HH:mm')).to.eql '2013-01-01 00:00' + + it 'counts pets', -> + pets = {} + expect(helpers.countPets(null, pets)).to.eql 0 + expect(helpers.countPets(1, pets)).to.eql 1 + + pets = { "Dragon-Red": 1, "Wolf-Base": 2 } + expect(helpers.countPets(null, pets)).to.eql 2 + expect(helpers.countPets(2, pets)).to.eql 2 + + pets = { "Wolf-Base": 2, "Wolf-Veteran": 1, "Wolf-Cerberus": 1, "Dragon-Hydra": 1} + expect(helpers.countPets(null, pets)).to.eql 1 + expect(helpers.countPets(_.size(pets), pets)).to.eql 1