|
|
@@ -0,0 +1,80 @@
|
|
|
+const { expect } = require('chai');
|
|
|
+const itEach = require('it-each');
|
|
|
+const moment = require('moment');
|
|
|
+
|
|
|
+const {
|
|
|
+ getPreviousWeekPeriod
|
|
|
+} = require('server/routes/annoy');
|
|
|
+
|
|
|
+describe('Annoy route', () => {
|
|
|
+ describe('getPreviousWeekPeriod', () => {
|
|
|
+ itEach();
|
|
|
+
|
|
|
+ it.each([
|
|
|
+ {
|
|
|
+ key: 'Monday-1',
|
|
|
+ now: '2019-01-14T06:00Z',
|
|
|
+ start: '2019-01-07T00:00:00.000Z',
|
|
|
+ end: '2019-01-13T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Tuesday-1',
|
|
|
+ now: '2019-01-15T06:00Z',
|
|
|
+ start: '2019-01-07T00:00:00.000Z',
|
|
|
+ end: '2019-01-13T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Wednesday-1',
|
|
|
+ now: '2019-01-16T06:00Z',
|
|
|
+ start: '2019-01-07T00:00:00.000Z',
|
|
|
+ end: '2019-01-13T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Thursday-1',
|
|
|
+ now: '2019-01-17T06:00Z',
|
|
|
+ start: '2019-01-07T00:00:00.000Z',
|
|
|
+ end: '2019-01-13T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Friday-1',
|
|
|
+ now: '2019-01-18T06:00Z',
|
|
|
+ start: '2019-01-07T00:00:00.000Z',
|
|
|
+ end: '2019-01-13T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Saturday-1',
|
|
|
+ now: '2019-01-19T06:00Z',
|
|
|
+ start: '2019-01-07T00:00:00.000Z',
|
|
|
+ end: '2019-01-13T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Sunday-1',
|
|
|
+ now: '2019-01-20T06:00Z',
|
|
|
+ start: '2019-01-07T00:00:00.000Z',
|
|
|
+ end: '2019-01-13T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Monday-2',
|
|
|
+ now: '2019-01-21T06:00Z',
|
|
|
+ start: '2019-01-14T00:00:00.000Z',
|
|
|
+ end: '2019-01-20T23:59:59.999Z'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: 'Tuesday-2',
|
|
|
+ now: '2019-01-21T06:00Z',
|
|
|
+ start: '2019-01-14T00:00:00.000Z',
|
|
|
+ end: '2019-01-20T23:59:59.999Z'
|
|
|
+ }
|
|
|
+ ], 'should fetch the start and end of the previous working week', ({ now, start, end }) => {
|
|
|
+
|
|
|
+ const {
|
|
|
+ start: startResult,
|
|
|
+ end: endResult
|
|
|
+ } = getPreviousWeekPeriod(moment(now));
|
|
|
+
|
|
|
+ expect(startResult.toISOString()).to.equal(start);
|
|
|
+ expect(endResult.toISOString()).to.equal(end);
|
|
|
+ });
|
|
|
+ });
|
|
|
+});
|
|
|
+
|