From 38acabfa6089ab8ac469c12b5f55022fb96935e5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 23 Aug 2021 16:46:06 -0300 Subject: added web vendors --- date-fns/src/isThisWeek/test.ts | 42 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 date-fns/src/isThisWeek/test.ts (limited to 'date-fns/src/isThisWeek/test.ts') diff --git a/date-fns/src/isThisWeek/test.ts b/date-fns/src/isThisWeek/test.ts new file mode 100644 index 0000000..e6e323d --- /dev/null +++ b/date-fns/src/isThisWeek/test.ts @@ -0,0 +1,42 @@ +// @flow +/* eslint-env mocha */ + +import assert from 'assert' +import sinon from 'sinon' +import isThisWeek from '.' + +describe('isThisWeek', () => { + let clock: sinon.SinonFakeTimers + beforeEach(() => { + clock = sinon.useFakeTimers(new Date(2014, 8 /* Sep */, 25).getTime()) + }) + + afterEach(() => { + clock.restore() + }) + + it('returns true if the given date and the current date have the same week', () => { + const date = new Date(2014, 8 /* Sep */, 21) + assert(isThisWeek(date) === true) + }) + + it('returns false if the given date and the current date have different weeks', () => { + const date = new Date(2014, 8 /* Sep */, 29) + assert(isThisWeek(date) === false) + }) + + it('allows to specify which day is the first day of the week', () => { + const date = new Date(2014, 8 /* Sep */, 28) + assert(isThisWeek(date, { weekStartsOn: 1 }) === true) + }) + + it('accepts a timestamp', () => { + const date = new Date(2014, 8 /* Sep */, 21).getTime() + assert(isThisWeek(date) === true) + }) + + it('throws TypeError exception if passed less than 1 argument', function() { + // @ts-expect-error + assert.throws(isThisWeek.bind(null), TypeError) + }) +}) -- cgit v1.2.3