Skip to content

Instantly share code, notes, and snippets.

@tatey
Last active January 4, 2016 21:09
Show Gist options
  • Save tatey/8678930 to your computer and use it in GitHub Desktop.
Save tatey/8678930 to your computer and use it in GitHub Desktop.
TimeRange.prototype.getEnd = function() {
var end = this.end;
if (end) {
return end;
} else {
return parseInt(this.start) + 3600 // 1 hour
}
};
describe('#getEnd', function() {
describe('when end is defined', function() {
it('returns end', function() {
var timeRange = new TimeRange({end: 1390089600});
expect(timeRange.getEnd()).toBe(1390089600);
});
});
describe('when end is undefined', function() {
it('returns start plus one hour', function() {
var timeRange = new TimeRange({start: 1390089600});
expect(timeRange.getEnd()).toBe(1390093200);
});
it('coerces start into an integer', function() {
var timeRange = new TimeRange({start: '1390089600'});
expect(timeRange.getEnd()).toBe(1390093200);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment