Skip to content

Commit

Permalink
copy should not create new moments if the date field is null
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham committed Aug 1, 2017
1 parent 4a200cb commit 8af16f6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
11 changes: 9 additions & 2 deletions opal/static/js/opal/services/episode.js
Expand Up @@ -154,12 +154,19 @@ angular.module('opal.services')
},

makeCopy: function(){
var start, end;
if(this.start){
start = moment(this.start);
}
if(this.end){
end = moment(this.end);
}
var copy = {
id : this.id,
category_name : this.category_name,
consistency_token: this.consistency_token,
start: moment(this.start),
end: moment(this.end)
start: start,
end: end
}
return copy
},
Expand Down
11 changes: 11 additions & 0 deletions opal/static/js/test/episode.service.test.js
Expand Up @@ -267,6 +267,17 @@ describe('Episode', function() {
expect(copy.end.toDate()).toEqual(new Date(2016, 4, 25));
});

it('start and end should be null if not set', function(){
var copy = episode.makeCopy();
delete copy.start;
delete copy.end;
expect(copy.id).toBe(123);
expect(copy.category_name).toBe('Inpatient');
expect(copy.consistency_token).toBe(undefined);
expect(copy.start).toEqual(undefined);
expect(copy.end).toEqual(undefined);
});

describe('communicating with server', function (){
var $httpBackend, episode;

Expand Down

0 comments on commit 8af16f6

Please sign in to comment.