From 9db46bd9992c3bea3f3a9dc898e7d2c08abaf5b5 Mon Sep 17 00:00:00 2001 From: Alys Date: Sun, 9 Aug 2015 16:32:35 +1000 Subject: [PATCH] add test for cron reducing the value of a todo by only one day's worth when multiple days are missed --- test/common/algos.mocha.coffee | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/common/algos.mocha.coffee b/test/common/algos.mocha.coffee index 3173ba5e55..5be39a7ae3 100644 --- a/test/common/algos.mocha.coffee +++ b/test/common/algos.mocha.coffee @@ -644,7 +644,7 @@ describe 'Cron', -> # paths = {};algos.cron user, {paths} # expect(paths.lastCron).to.be true # busted cron (was set to after today's date) - it 'only dailies & todos are effected', -> + it 'only dailies & todos are affected', -> {before,after} = beforeAfter({daysAgo:1}) before.dailys = before.todos = after.dailys = after.todos = [] after.fns.cron() @@ -732,9 +732,19 @@ describe 'Cron', -> expect(after).toHaveGP 0 # but they devalue - expect(after.todos[0].value).to.be.lessThan before.todos[0].value + expect(before.todos[0].value).to.be 0 # sanity check for task setup + expect(after.todos[0].value).to.be -1 # the actual test expect(after.history.todos).to.have.length 1 + it '2 days missed', -> + {before,after} = beforeAfter({daysAgo:2}) + before.dailys = after.dailys = [] + after.fns.cron() + + # todos devalue by only one day's worth of devaluation + expect(before.todos[0].value).to.be 0 # sanity check for task setup + expect(after.todos[0].value).to.be -1 # the actual test + # I used hard-coded dates here instead of 'now' so the tests don't fail # when you run them between midnight and dayStart. Nothing worse than # intermittent failures.