Skip to content

Commit

Permalink
Add test for filtering periods and correct stream error
Browse files Browse the repository at this point in the history
  • Loading branch information
Markionium committed Apr 7, 2017
1 parent 6488b09 commit ea458b9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/period/period-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function periodService(dataStore, rx, $rootScope) {
return rx.Observable.fromPromise(dataStore.getPeriodSettings())
.map(onlyPeriodsForWorkflow(workflow))
.map(periodSettingsToArray)
.filter(onlyOpenPeriods)
.map(onlyOpenPeriods)
.map(onlyNameAndIdProperties)
.safeApply($rootScope);
}
Expand All @@ -40,7 +40,7 @@ function periodService(dataStore, rx, $rootScope) {
var start = Date.parse(startDate);
var end = Date.parse(endDate);
var now = Date.now();

if (isNumber(start) && isNumber(end)) {
return (start < now) && (now < end);
}
Expand Down
7 changes: 6 additions & 1 deletion src/test/specs/period/period-service_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ describe('Period service', function () {
periodSettingMock = sinon.stub()
.returns($q.when({
"MER Results": { // Id of dataApprovalWorkflow
"2016Q2": {
"name": "April - June 2016",
"start": "Mar 3 2017 21:00:00 GMT+0200",
"end": "Mar 4 2017 21:00:00 GMT+0200"
},
"2017Q1": {
"name": "January - March 2017",
"start": 'Fri Mar 31 2017 21:00:00 GMT+0200',
Expand Down Expand Up @@ -63,7 +68,7 @@ describe('Period service', function () {
expect(periodsForWorkflow$.subscribe).to.be.a('function');
});

it('should return the periods for just the workflow', function (done) {
it('should return the open periods for the workflow', function (done) {
var periodsForWorkflow$ = service.getPeriodsForWorkflow({ id: 'QeGps9iWl1i', name: 'MER Results' });

periodsForWorkflow$.subscribe(
Expand Down

0 comments on commit ea458b9

Please sign in to comment.