Last active
October 16, 2016 20:17
-
-
Save emilong/1c206eb3e965d043426add69125d7235 to your computer and use it in GitHub Desktop.
This file contains 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
const moment = require('moment'); | |
const PERIOD = moment.duration(3, 'days'); | |
module.exports = { | |
PERIOD, | |
isWithinPeriod(test) { | |
return moment().add(PERIOD).isAfter(test); | |
}, | |
}; | |
/// meanwhile, in our test file... | |
const timeUtils = require('./time-utils'); | |
describe('timeUtils.isWithinPeriod', () => { | |
it('is false for a time beyond its own defined period', () => { | |
const beyondPeriod = moment().add(timeUtils.PERIOD).add(timeUtils.PERIOD); | |
assert(timeUtils.isWithinPeriod(beyondPeriod) === false); | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment