MErged in develop
This commit is contained in:
@@ -208,6 +208,13 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
expect(task.completed).to.equal(false);
|
||||
});
|
||||
|
||||
it('computes isDue', async () => {
|
||||
await user.post(`/tasks/${daily._id}/score/up`);
|
||||
let task = await user.get(`/tasks/${daily._id}`);
|
||||
|
||||
expect(task.isDue).to.equal(true);
|
||||
});
|
||||
|
||||
it('scores up daily even if it is already completed'); // Yes?
|
||||
|
||||
it('scores down daily even if it is already uncompleted'); // Yes?
|
||||
|
||||
@@ -509,6 +509,7 @@ describe('POST /tasks/user', () => {
|
||||
expect(task.daysOfMonth).to.eql([15]);
|
||||
expect(task.weeksOfMonth).to.eql([3]);
|
||||
expect(new Date(task.startDate)).to.eql(now);
|
||||
expect(task.isDue).to.be.true;
|
||||
});
|
||||
|
||||
it('creates multiple dailys', async () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import moment from 'moment';
|
||||
import {
|
||||
generateUser,
|
||||
generateGroup,
|
||||
@@ -395,12 +396,14 @@ describe('PUT /tasks/:id', () => {
|
||||
notes: 'some new notes',
|
||||
frequency: 'daily',
|
||||
everyX: 5,
|
||||
startDate: moment().add(1, 'days').toDate(),
|
||||
});
|
||||
|
||||
expect(savedDaily.text).to.eql('some new text');
|
||||
expect(savedDaily.notes).to.eql('some new notes');
|
||||
expect(savedDaily.frequency).to.eql('daily');
|
||||
expect(savedDaily.everyX).to.eql(5);
|
||||
expect(savedDaily.isDue).to.be.false;
|
||||
});
|
||||
|
||||
it('can update checklists (replace it)', async () => {
|
||||
|
||||
@@ -358,6 +358,14 @@ describe('cron', () => {
|
||||
};
|
||||
});
|
||||
|
||||
it('computes isDue', () => {
|
||||
tasksByType.dailys[0].frequency = 'daily';
|
||||
tasksByType.dailys[0].everyX = 5;
|
||||
tasksByType.dailys[0].startDate = moment().add(1, 'days').toDate();
|
||||
cron({user, tasksByType, daysMissed, analytics});
|
||||
expect(tasksByType.dailys[0].isDue).to.be.false;
|
||||
});
|
||||
|
||||
it('should add history', () => {
|
||||
cron({user, tasksByType, daysMissed, analytics});
|
||||
expect(tasksByType.dailys[0].history).to.be.lengthOf(1);
|
||||
|
||||
@@ -7,7 +7,6 @@ describe('shouldDo', () => {
|
||||
let options = {};
|
||||
|
||||
beforeEach(() => {
|
||||
options = {};
|
||||
day = new Date();
|
||||
dailyTask = {
|
||||
completed: 'false',
|
||||
@@ -215,8 +214,9 @@ describe('shouldDo', () => {
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||
});
|
||||
|
||||
it('returns true on the Start Date', () => {
|
||||
dailyTask.startDate = moment().toDate();
|
||||
it('returns true on multiples of x', () => {
|
||||
dailyTask.startDate = moment().subtract(7, 'days').toDate();
|
||||
dailyTask.everyX = 7;
|
||||
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||
});
|
||||
@@ -279,10 +279,8 @@ describe('shouldDo', () => {
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||
});
|
||||
|
||||
it('returns false for today', () => {
|
||||
dailyTask.startDate = moment().toDate();
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||
});
|
||||
day = moment(day).add(7, 'days');
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user