From c6511ed829375ba1d36ce358008d2a63e4e3ef14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20W=C3=BCrtz?= Date: Sun, 7 Jul 2019 17:17:22 -0300 Subject: [PATCH] test(ganttDb.spec): add simple tests for the durationToDate fn --- src/diagrams/gantt/ganttDb.spec.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/diagrams/gantt/ganttDb.spec.js b/src/diagrams/gantt/ganttDb.spec.js index 6bea54bc5..1dad71ad6 100644 --- a/src/diagrams/gantt/ganttDb.spec.js +++ b/src/diagrams/gantt/ganttDb.spec.js @@ -7,6 +7,16 @@ describe('when using the ganttDb', function () { ganttDb.clear() }) + describe('when using relative times', function () { + it.each` + diff | date | expected + ${' 1d'} | ${moment('2019-01-01')} | ${moment('2019-01-02').toDate()} + ${' 1w'} | ${moment('2019-01-01')} | ${moment('2019-01-08').toDate()} + `('should add $diff to $date resulting in $expected', ({ diff, date, expected }) => { + expect(ganttDb.durationToDate(diff, date)).toEqual(expected) +}) + }) + describe('when calling the clear function', function () { beforeEach(function () { ganttDb.setDateFormat('YYYY-MM-DD')