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/startOfDay/test.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 date-fns/src/startOfDay/test.ts (limited to 'date-fns/src/startOfDay/test.ts') diff --git a/date-fns/src/startOfDay/test.ts b/date-fns/src/startOfDay/test.ts new file mode 100644 index 0000000..a699302 --- /dev/null +++ b/date-fns/src/startOfDay/test.ts @@ -0,0 +1,35 @@ +// @flow +/* eslint-env mocha */ + +import assert from 'power-assert' +import startOfDay from '.' + +describe('startOfDay', function() { + it('returns the date with the time set to 00:00:00', function() { + const date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + const result = startOfDay(date) + assert.deepEqual(result, new Date(2014, 8 /* Sep */, 2, 0, 0, 0, 0)) + }) + + it('accepts a timestamp', function() { + const date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0).getTime() + const result = startOfDay(date) + assert.deepEqual(result, new Date(2014, 8 /* Sep */, 2, 0, 0, 0, 0)) + }) + + it('does not mutate the original date', function() { + const date = new Date(2014, 8 /* Sep */, 2, 11, 55, 0) + startOfDay(date) + assert.deepEqual(date, new Date(2014, 8 /* Sep */, 2, 11, 55, 0)) + }) + + it('returns `Invalid Date` if the given date is invalid', function() { + const result = startOfDay(new Date(NaN)) + //@ts-expect-error + assert(result instanceof Date && isNaN(result)) + }) + + it('throws TypeError exception if passed less than 1 argument', function() { + assert.throws(startOfDay.bind(null), TypeError) + }) +}) -- cgit v1.2.3