Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.