Skip to content

Commit

Permalink
Add tests for scheduled_tasks-based nools task generation
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Jul 9, 2018
1 parent ad06e96 commit 6b1dc93
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/nools/lib.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,30 @@ describe('nools lib', function() {
});

});

describe('scheduled-task based', function() {
it('???', function() {
// given
const config = {
c: personWithReports(aReportWithScheduledTasks(5)),
targets: [],
tasks: [ aScheduledTaskBasedTask() ],
};

// when
const emitted = loadLibWith(config).emitted;

// then
assert.deepEqual(emitted, [
{ _type:'task' },
{ _type:'task' },
{ _type:'task' },
{ _type:'task' },
{ _type:'task' },
{ _type:'_complete', _id:true },
]);
});
});
});

function loadLibWith({ c, targets, tasks }) {
Expand Down Expand Up @@ -328,6 +352,22 @@ describe('nools lib', function() {
};
}

function aScheduledTaskBasedTask() {
++idCounter;
return {
appliesToType: 'report',
name: `task-${idCounter}`,
title: [ { locale:'en', content:`Task ${idCounter}` } ],
actions: [],
events: [ {
id: `task-${idCounter}`,
days:0, start:0, end:1,
} ],
resolvedIf: function() { return false; },
appliesToScheduledTaskIf: function() { return true; },
};
}

function aPersonBasedTarget() {
++idCounter;
return {
Expand All @@ -349,6 +389,15 @@ describe('nools lib', function() {
return { _id:`r-${idCounter}`, form:'F' };
}

function aReportWithScheduledTasks(scheduledTaskCount) {
++idCounter;

const scheduled_tasks = [];
while(scheduledTaskCount--) scheduled_tasks.push({});

return { _id:`r-${idCounter}`, form:'F', scheduled_tasks };
}

function personWithoutReports() {
return personWithReports();
}
Expand Down

0 comments on commit 6b1dc93

Please sign in to comment.