Skip to content

Instantly share code, notes, and snippets.

@emilong
Last active October 16, 2016 20:17
Show Gist options
  • Save emilong/1c206eb3e965d043426add69125d7235 to your computer and use it in GitHub Desktop.
Save emilong/1c206eb3e965d043426add69125d7235 to your computer and use it in GitHub Desktop.
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