Mailspring/spec/date-utils-spec.es6

46 lines
1.6 KiB
Plaintext
Raw Normal View History

import moment from 'moment'
import {DateUtils} from 'nylas-exports'
describe('DateUtils', function dateUtils() {
2016-05-06 13:30:34 +08:00
describe('nextWeek', () => {
it('returns tomorrow if now is sunday', () => {
const sunday = moment("03-06-2016", "MM-DD-YYYY")
const nextWeek = DateUtils.nextWeek(sunday)
expect(nextWeek.format('MM-DD-YYYY')).toEqual('03-07-2016')
});
2016-05-06 13:30:34 +08:00
it('returns next monday if now is monday', () => {
const monday = moment("03-07-2016", "MM-DD-YYYY")
const nextWeek = DateUtils.nextWeek(monday)
expect(nextWeek.format('MM-DD-YYYY')).toEqual('03-14-2016')
});
2016-05-06 13:30:34 +08:00
it('returns next monday', () => {
const saturday = moment("03-05-2016", "MM-DD-YYYY")
const nextWeek = DateUtils.nextWeek(saturday)
expect(nextWeek.format('MM-DD-YYYY')).toEqual('03-07-2016')
});
});
2016-05-06 13:30:34 +08:00
describe('thisWeekend', () => {
it('returns tomorrow if now is friday', () => {
const friday = moment("03-04-2016", "MM-DD-YYYY")
const thisWeekend = DateUtils.thisWeekend(friday)
expect(thisWeekend.format('MM-DD-YYYY')).toEqual('03-05-2016')
});
2016-05-06 13:30:34 +08:00
it('returns next saturday if now is saturday', () => {
const saturday = moment("03-05-2016", "MM-DD-YYYY")
const thisWeekend = DateUtils.thisWeekend(saturday)
expect(thisWeekend.format('MM-DD-YYYY')).toEqual('03-12-2016')
});
2016-05-06 13:30:34 +08:00
it('returns next saturday', () => {
const sunday = moment("03-06-2016", "MM-DD-YYYY")
const thisWeekend = DateUtils.thisWeekend(sunday)
expect(thisWeekend.format('MM-DD-YYYY')).toEqual('03-12-2016')
});
});
});