Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Interval#isBefore returns true for intervals fully before the input', () => {
let n = Instant.fromISO('1982-05-25T06:00'),
i = Interval.fromInstants(n.minus(2, 'day'), n.minus(1, 'day'));
expect(i.isBefore(n)).toBeTruthy();
});
it('Interval#isAfter returns false for intervals containing the input', () => {
let n = Instant.fromISO('1982-05-25T06:00'),
i = Interval.fromInstants(n.minus(2, 'day'), n.plus(2, 'day'));
expect(i.isAfter(n)).toBeFalsy();
});
it('Interval#contains returns false for instants after the interval', () => {
let i = fromISOs('1982-05-25T06:00', '1982-05-25T07:00');
expect(i.contains(Instant.fromISO('1982-05-25T08:30'))).toBeFalsy();
});
it("Interval#count('days') returns 2 if the interval crosses midnight", () => {
let i = Instant.fromISO('2016-05-25T03:00').until(Instant.fromISO('2016-05-26T14:00'));
expect(i.count('days')).toBe(2);
});
it('Interval#contains returns false for instants before the interval', () => {
let i = fromISOs('1982-05-25T06:00', '1982-05-25T07:00');
expect(i.contains(Instant.fromISO('1982-05-25T05:30'))).toBeFalsy();
});
it("Interval#count('days') returns 1 inside a day", () => {
let i = Instant.fromISO('2016-05-25T03:00').until(Instant.fromISO('2016-05-25T14:00'));
expect(i.count('days')).toBe(1);
});
it('Interval#isAfter returns true for intervals fully after the input', () => {
let n = Instant.fromISO('1982-05-25T06:00'),
i = Interval.fromInstants(n.plus(1, 'day'), n.plus(2, 'day'));
expect(i.isAfter(n)).toBeTruthy();
});
it('Instant.fromISO() parses as local by default', () => {
let inst = Instant.fromISO("2016-05-25T09:08:34.123");
expect(inst.toObject()).toEqual(
{year: 2016, month: 5, day: 25, hour: 9, minute: 8, second: 34, millisecond: 123}
);
});
let rejects = (s) => expect(Instant.fromISO(s).isValid()).toBeFalsy();
let fromISOs = (s, e, opts = {}) => Instant.fromISO(s).until(Instant.fromISO(e), opts),
todayAt = (h) => Instant.now().startOf('day').hour(h),