Skip to content

Instantly share code, notes, and snippets.

@webdesignberlin
Forked from emilong/no-bind-util-object.js
Created October 16, 2016 20:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webdesignberlin/cf1ae584db9a071beee5562d474b5288 to your computer and use it in GitHub Desktop.
Save webdesignberlin/cf1ae584db9a071beee5562d474b5288 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