Last active
January 4, 2016 21:09
-
-
Save tatey/8678930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TimeRange.prototype.getEnd = function() { | |
var end = this.end; | |
if (end) { | |
return end; | |
} else { | |
return parseInt(this.start) + 3600 // 1 hour | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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