diff --git a/__tests__/Date/wtf.unit.spec.js b/__tests__/Date/wtf.unit.spec.js index 0d7625b..91ac5b9 100644 --- a/__tests__/Date/wtf.unit.spec.js +++ b/__tests__/Date/wtf.unit.spec.js @@ -1,18 +1,23 @@ +/** + * @jest-environment jsdom + */ + // SRC: https://jsdate.wtf/ describe('Date', () => { 'use strict' - let oDate, dateString, dateValue, milliseconds + let oDate, dateISOString, dateTimeString, dateValue, milliseconds // 1 of 28 describe('new Date("0")', () => { beforeEach(() => { oDate = new Date('0') - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() + dateTimeString = oDate.toTimeString() }) it('does NOT equal "1970-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('1970-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('1970-01-01T00:00:00.000Z') }) it('interprets "0" as the year 2000, not as a timestamp! parsing it as "2000-01-01T06:00:00.000"', () => { @@ -27,17 +32,17 @@ describe('Date', () => { describe('new Date(0)', () => { beforeEach(() => { oDate = new Date(0) - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "2000-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2000-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('2000-01-01T00:00:00.000Z') }) it('is interpreted as 0 milliseconds since the Unix epoch (Jan 1, 1970).', () => { // The number 0, as opposed to the string "0", // is interpreted as milliseconds since the Unix epoch (Jan 1, 1970). - expect(dateString).toEqual('1970-01-01T00:00:00.000Z') + expect(dateISOString).toEqual('1970-01-01T00:00:00.000Z') }) }) @@ -116,20 +121,20 @@ describe('Date', () => { // 7 of 28 describe('.toTimeString()', () => { beforeEach(() => { - dateString = oDate.toTimeString() + dateTimeString = oDate.toTimeString() }) it('does NOT equal ""', () => { - expect(dateString).not.toEqual('') + expect(dateTimeString).not.toEqual('') }) it('is NOT null', () => { - expect(dateString).not.toBe(null) + expect(dateTimeString).not.toBe(null) }) it('returns the string "Invalid Date" for invalid dates. 🫠', () => { // toTimeString() returns the string "Invalid Date" for invalid dates. 🫠 - expect(dateString).toEqual('Invalid Date') + expect(dateTimeString).toEqual('Invalid Date') }) }) }) @@ -138,15 +143,15 @@ describe('Date', () => { describe('new Date("1")', () => { beforeEach(() => { oDate = new Date('1') - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "1970-01-01T00:00:00.001Z"', () => { - expect(dateString).not.toEqual('1970-01-01T00:00:00.001Z') + expect(dateISOString).not.toEqual('1970-01-01T00:00:00.001Z') }) it('does NOT equal "0001-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('0001-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('0001-01-01T00:00:00.000Z') }) it('equals to "2001-01-01T00:00:00.000"', () => { @@ -162,15 +167,15 @@ describe('Date', () => { describe('new Date("2")', () => { beforeEach(() => { oDate = new Date('2') - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "2002-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2002-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('2002-01-01T00:00:00.000Z') }) it('does NOT equal "2001-01-02T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-01-02T00:00:00.000Z') + expect(dateISOString).not.toEqual('2001-01-02T00:00:00.000Z') }) it('equals "2001-02-01T00:00:00.000"', () => { @@ -184,15 +189,15 @@ describe('Date', () => { describe('new Date("12")', () => { beforeEach(() => { oDate = new Date('12') - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "2012-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2012-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('2012-01-01T00:00:00.000Z') }) it('does NOT equal "2001-01-12T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-01-12T00:00:00.000Z') + expect(dateISOString).not.toEqual('2001-01-12T00:00:00.000Z') }) it('equals "2001-12-01T00:00:00.000"', () => { @@ -207,7 +212,7 @@ describe('Date', () => { describe('new Date("13")', () => { beforeEach(() => { oDate = new Date('13') - dateString = oDate.toTimeString() + dateTimeString = oDate.toTimeString() }) describe('.toISOString()', () => { @@ -219,7 +224,7 @@ describe('Date', () => { describe('.toTimeString()', () => { it('equals "Invalid Date"', () => { // "13" would be month 13, which doesn't exist, so it's Invalid Date. - expect(dateString).toEqual('Invalid Date') + expect(dateTimeString).toEqual('Invalid Date') }) }) }) @@ -255,36 +260,58 @@ describe('Date', () => { describe('new Date("12.1")', () => { beforeEach(() => { oDate = new Date('12.1') - dateString = oDate.toISOString() - }) - - it('does NOT equal "2001-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-01-01T00:00:00.000Z') }) - it('does NOT equal "2012-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2012-01-01T00:00:00.000Z') - }) + if (isFireFox()) { // v 143.0 + describe('@FireFox', () => { + describe('.toISOString()', () => { + it('throws', () => { + expect(() => oDate.toISOString()).toThrow() + }) + }) - it('equals "2001-12-01T00:00:00.000"', () => { - // "12.1" is interpreted as the date December 1st, - // and as before for dates with no year the default is 2001 because of course. - // expect(dateString).toEqual('2001-12-01T00:00:00.000Z') - const expectedDate = new Date('2001-12-01T00:00:00.000') - expect(oDate.getTime()).toEqual(expectedDate.getTime()) - }) + describe('.toTimeString()', () => { + it('equals "Invalid Date"', () => { + expect(dateTimeString).toEqual('Invalid Date') + }) + }) + }) + } else { + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here: "Invalid Date". + dateISOString = oDate.toISOString() + }) + + it('does NOT equal "2001-01-01T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-01-01T00:00:00.000Z') + }) + + it('does NOT equal "2012-01-01T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2012-01-01T00:00:00.000Z') + }) + + it('equals "2001-12-01T00:00:00.000"', () => { + // "12.1" is interpreted as the date December 1st, + // and as before for dates with no year the default is 2001 because of course. + // expect(dateString).toEqual('2001-12-01T00:00:00.000Z') + const expectedDate = new Date('2001-12-01T00:00:00.000') + expect(oDate.getTime()).toEqual(expectedDate.getTime()) + }) + }) + } }) // 15 of 28 describe('new Date("12.0")', () => { beforeEach(() => { oDate = new Date('12.0') - dateString = oDate.toTimeString() + dateTimeString = oDate.toTimeString() }) describe('.toTimeString()', () => { it('equals "Invalid Date"', () => { - expect(dateString).toEqual('Invalid Date') + expect(dateTimeString).toEqual('Invalid Date') }) }) @@ -299,34 +326,56 @@ describe('Date', () => { describe('new Date("12.-1")', () => { beforeEach(() => { oDate = new Date('12.-1') - dateString = oDate.toISOString() }) - it('does NOT equal "2012-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2012-01-01T00:00:00.000Z') - }) - - it('does NOT equal "2001-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-01-01T00:00:00.000Z') - }) + if (isFireFox()) { // v 143.0 + describe('@FireFox', () => { + describe('.toISOString()', () => { + it('throws', () => { + expect(() => oDate.toISOString()).toThrow() + }) + }) - it('ignores the "-", interpreting it like "12.1", resulting in "2001-12-01T00:00:00.000"', () => { - // The dash here is ignored, so this is interpreted the same as "12.1". - // expect(dateString).toEqual('2001-12-01T00:00:00.000Z') - const expectedDate = new Date('2001-12-01T00:00:00.000') - expect(oDate.getTime()).toEqual(expectedDate.getTime()) - }) + describe('.toTimeString()', () => { + it('equals "Invalid Date"', () => { + expect(dateTimeString).toEqual('Invalid Date') + }) + }) + }) + } else { + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here "Invalid Date". + dateISOString = oDate.toISOString() + }) + + it('does NOT equal "2012-01-01T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2012-01-01T00:00:00.000Z') + }) + + it('does NOT equal "2001-01-01T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-01-01T00:00:00.000Z') + }) + + it('ignores the "-", interpreting it like "12.1", resulting in "2001-12-01T00:00:00.000"', () => { + // The dash here is ignored, so this is interpreted the same as "12.1". + // expect(dateString).toEqual('2001-12-01T00:00:00.000Z') + const expectedDate = new Date('2001-12-01T00:00:00.000') + expect(oDate.getTime()).toEqual(expectedDate.getTime()) + }) + }) + } }) // 17 of 28 describe('new Date("perhaps 1")', () => { beforeEach(() => { oDate = new Date('perhaps 1') - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "1970-01-01T00:00:01.000Z"', () => { - expect(dateString).not.toEqual('1970-01-01T00:00:01.000Z') + expect(dateISOString).not.toEqual('1970-01-01T00:00:01.000Z') }) it('ignores leading text. Finding "1" and parsing it as January. Resulting in "2001-01-01T00:00:00.000"', () => { @@ -345,12 +394,12 @@ describe('Date', () => { // It needs a number to parse, so this is Invalid Date. // It's equivalent to new Date(""). oDate = new Date('perhaps') - dateString = oDate.toTimeString() + dateTimeString = oDate.toTimeString() }) describe('.toTimeString()', () => { it('equals "Invalid Date"', () => { - expect(dateString).toEqual('Invalid Date') + expect(dateTimeString).toEqual('Invalid Date') }) }) @@ -368,23 +417,45 @@ describe('Date', () => { // And for some reason this expression cares about your local timezone, // which happens to be BST for me right now. oDate = new Date('maybe 1') - dateString = oDate.toISOString() }) - // WARNING: The quiz says this is the correct answer! - it('does NOT equal "2001-04-30T23:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-04-30T23:00:00.000Z') - }) + if (isFireFox()) { // v 143.0 + describe('@FireFox', () => { + describe('.toISOString()', () => { + it('throws', () => { + expect(() => oDate.toISOString()).toThrow() + }) + }) - it('does NOT equal "2001-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-01-01T00:00:00.000Z') - }) - - it('parses "maybe" as "may"! resulting in "2001-05-01T00:00:00.000"', () => { - // expect(dateString).toEqual('2001-05-01T00:00:00.000Z') - const expectedDate = new Date('2001-05-01T00:00:00.000') - expect(oDate.getTime()).toEqual(expectedDate.getTime()) - }) + describe('.toTimeString()', () => { + it('equals "Invalid Date"', () => { + expect(dateTimeString).toEqual('Invalid Date') + }) + }) + }) + } else { + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here: "Invalid Date". + dateISOString = oDate.toISOString() + }) + + // WARNING: The quiz says this is the correct answer! + it('does NOT equal "2001-04-30T23:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-04-30T23:00:00.000Z') + }) + + it('does NOT equal "2001-01-01T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-01-01T00:00:00.000Z') + }) + + it('parses "maybe" as "may"! resulting in "2001-05-01T00:00:00.000"', () => { + // expect(dateString).toEqual('2001-05-01T00:00:00.000Z') + const expectedDate = new Date('2001-05-01T00:00:00.000') + expect(oDate.getTime()).toEqual(expectedDate.getTime()) + }) + }) + } }) // 20 of 28 @@ -394,23 +465,46 @@ describe('Date', () => { // this is just parsing "may 2010" // and again local timezone is important. oDate = new Date('fourth of may 2010') - dateString = oDate.toISOString() }) - // Works only in non-UTC timezones. - xit('does NOT equal "2010-05-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2010-05-01T00:00:00.000Z') - }) + if (isFireFox()) { // v 143.0 + describe('@FireFox', () => { + describe('.toISOString()', () => { + it('throws', () => { + expect(() => oDate.toISOString()).toThrow() + }) + }) - it('does NOT equal "2010-05-04T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2010-05-04T00:00:00.000Z') - }) - - it('ignores "fourth of", parsing "may 2010" as "2010-05-01T00:00:00.000"', () => { - // expect(dateString).toEqual('2010-05-01T00:00:00.000Z') - const expectedDate = new Date('2010-05-01T00:00:00.000') - expect(oDate.getTime()).toEqual(expectedDate.getTime()) - }) + describe('.toTimeString()', () => { + it('equals "Invalid Date"', () => { + expect(dateTimeString).toEqual('Invalid Date') + }) + }) + }) + } else { + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here: "Invalid Date". + dateISOString = oDate.toISOString() + }) + + // Only works in Non-UTC + xit('does NOT equal "2010-05-01T00:00:00.000"', () => { + const expectedDate = new Date('2010-05-01T00:00:00.000') + expect(oDate.getTime()).not.toEqual(expectedDate.getTime()) + }) + + it('does NOT equal "2010-05-04T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2010-05-04T00:00:00.000Z') + }) + + it('ignores "fourth of", parsing "may 2010" as "2010-05-01T00:00:00.000"', () => { + // expect(dateString).toEqual('2010-05-01T00:00:00.000Z') + const expectedDate = new Date('2010-05-01T00:00:00.000') + expect(oDate.getTime()).toEqual(expectedDate.getTime()) + }) + }) + } }) // 21 of 28 @@ -418,20 +512,42 @@ describe('Date', () => { beforeEach(() => { // UTC is correctly parsed as a timezone. oDate = new Date('May 4 UTC') - dateString = oDate.toISOString() - }) - - it('does NOT equal "2010-04-30T23:00:00.000Z"', () => { - expect(dateString).not.toEqual('2010-04-30T23:00:00.000Z') }) - it('does NOT equal "2010-05-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2010-05-01T00:00:00.000Z') - }) + if (isFireFox()) { // v 143.0 + describe('@FireFox', () => { + describe('.toISOString()', () => { + it('throws', () => { + expect(() => oDate.toISOString()).toThrow() + }) + }) - it('parses UTC as "2001-05-04T00:00:00.000Z"', () => { - expect(dateString).toEqual('2001-05-04T00:00:00.000Z') - }) + describe('.toTimeString()', () => { + it('equals "Invalid Date"', () => { + expect(dateTimeString).toEqual('Invalid Date') + }) + }) + }) + } else { + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here: "Invalid Date". + dateISOString = oDate.toISOString() + }) + + it('does NOT equal "2010-04-30T23:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2010-04-30T23:00:00.000Z') + }) + + it('does NOT equal "2010-05-01T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2010-05-01T00:00:00.000Z') + }) + + it('parses UTC as "2001-05-04T00:00:00.000Z"', () => { + expect(dateISOString).toEqual('2001-05-04T00:00:00.000Z') + }) + }) + } }) // 22 of 28 @@ -439,21 +555,43 @@ describe('Date', () => { beforeEach(() => { // You can add modifiers to timezones and it works as you would expect. oDate = new Date('May 4 UTC+1') - dateString = oDate.toISOString() }) - it('does NOT equal "2001-05-04T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-05-04T00:00:00.000Z') - }) + if (isFireFox()) { // v 143.0 + describe('@FireFox', () => { + describe('.toISOString()', () => { + it('throws', () => { + expect(() => oDate.toISOString()).toThrow() + }) + }) - it('does NOT equal "2010-05-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2010-05-01T00:00:00.000Z') - }) - - it('parses UTC+1 as "2001-05-04T00:00:00.000", resulting in "2001-05-03T23:00:00.000Z"', () => { - // 05-04T00 @ UTC+1 is 1 hr ahead: 05-03T23 @ UTC - expect(dateString).toEqual('2001-05-03T23:00:00.000Z') - }) + describe('.toTimeString()', () => { + it('equals "Invalid Date"', () => { + expect(dateTimeString).toEqual('Invalid Date') + }) + }) + }) + } else { + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here: "Invalid Date". + dateISOString = oDate.toISOString() + }) + + it('does NOT equal "2001-05-04T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-05-04T00:00:00.000Z') + }) + + it('does NOT equal "2010-05-01T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2010-05-01T00:00:00.000Z') + }) + + it('parses UTC+1 as "2001-05-04T00:00:00.000", resulting in "2001-05-03T23:00:00.000Z"', () => { + // 05-04T00 @ UTC+1 is 1 hr ahead: 05-03T23 @ UTC + expect(dateISOString).toEqual('2001-05-03T23:00:00.000Z') + }) + }) + } }) // 23 of 28 @@ -461,16 +599,38 @@ describe('Date', () => { beforeEach(() => { // It also supports minutes! oDate = new Date('May 4 UTC+1:59') - dateString = oDate.toISOString() }) - it('does NOT equal "2001-05-04T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-05-04T00:00:00.000Z') - }) + if (isFireFox()) { // v 143.0 + describe('@FireFox', () => { + describe('.toISOString()', () => { + it('throws', () => { + expect(() => oDate.toISOString()).toThrow() + }) + }) - it('parses UTC+1:59 as "2001-05-04T00:00:00.000", resulting in "2001-05-03T22:01:00.000Z"', () => { - expect(dateString).toEqual('2001-05-03T22:01:00.000Z') - }) + describe('.toTimeString()', () => { + it('equals "Invalid Date"', () => { + expect(dateTimeString).toEqual('Invalid Date') + }) + }) + }) + } else { + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here: "Invalid Date". + dateISOString = oDate.toISOString() + }) + + it('does NOT equal "2001-05-04T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-05-04T00:00:00.000Z') + }) + + it('parses UTC+1:59 as "2001-05-04T00:00:00.000", resulting in "2001-05-03T22:01:00.000Z"', () => { + expect(dateISOString).toEqual('2001-05-03T22:01:00.000Z') + }) + }) + } }) // 24 of 28 @@ -480,19 +640,25 @@ describe('Date', () => { // 60 is being parsed as the year here, // UTC+1 is the timezone. oDate = new Date('May 4 UTC+1:60') - dateString = oDate.toISOString() }) - it('does NOT equal "2001-05-04T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-05-04T00:00:00.000Z') - }) + describe('.toISOString()', () => { + beforeEach(() => { + // NOTE: FireFox throws here: "Invalid Date". + dateISOString = oDate.toISOString() + }) - it('does NOT equal "2001-05-03T22:00:00.000Z"', () => { - expect(dateString).not.toEqual('2001-05-03T22:00:00.000Z') - }) + it('does NOT equal "2001-05-04T00:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-05-04T00:00:00.000Z') + }) - it('parses UTC+1:60 as "UTC+1" AND "year 60"!, resulting in "1960-05-03T23:00:00.000Z"', () => { - expect(dateString).toEqual('1960-05-03T23:00:00.000Z') + it('does NOT equal "2001-05-03T22:00:00.000Z"', () => { + expect(dateISOString).not.toEqual('2001-05-03T22:00:00.000Z') + }) + + it('parses UTC+1:60 as "UTC+1" AND "year 60"!, resulting in "1960-05-03T23:00:00.000Z"', () => { + expect(dateISOString).toEqual('1960-05-03T23:00:00.000Z') + }) }) }) @@ -501,12 +667,12 @@ describe('Date', () => { beforeEach(() => { // No tricks here, just a plain ol' Invalid Date. oDate = new Date('1990 2010') - dateString = oDate.toTimeString() + dateTimeString = oDate.toTimeString() }) describe('.toTimeString()', () => { it('equals "Invalid Date"', () => { - expect(dateString).toEqual('Invalid Date') + expect(dateTimeString).toEqual('Invalid Date') }) }) @@ -522,15 +688,15 @@ describe('Date', () => { beforeEach(() => { // For some reason, parenthesised text is ignored. oDate = new Date('1990 (2010)') - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "2000-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2000-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('2000-01-01T00:00:00.000Z') }) it('does NOT equal "2010-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2010-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('2010-01-01T00:00:00.000Z') }) it('ignores text in parentheses, parsing this as "1990", resulting in "1990-01-01T00:00:00.000"', () => { @@ -545,15 +711,15 @@ describe('Date', () => { beforeEach(() => { // No matter where it is. oDate = new Date('(1990) 2010') - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "1990-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('1990-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('1990-01-01T00:00:00.000Z') }) it('does NOT equal "2000-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2000-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('2000-01-01T00:00:00.000Z') }) it('ignores text in parentheses, parsing this as "2010", resulting in "2010-01-01T00:00:00.000"', () => { @@ -569,15 +735,15 @@ describe('Date', () => { // -[] is coerced to 0, // which is interpreted as milliseconds since the Unix epoch (Jan 1, 1970). oDate = new Date(-[]) - dateString = oDate.toISOString() + dateISOString = oDate.toISOString() }) it('does NOT equal "2000-01-01T00:00:00.000Z"', () => { - expect(dateString).not.toEqual('2000-01-01T00:00:00.000Z') + expect(dateISOString).not.toEqual('2000-01-01T00:00:00.000Z') }) it('coerces -[] as 0, parsing it to "1970-01-01T00:00:00.000Z"', () => { - expect(dateString).toEqual('1970-01-01T00:00:00.000Z') + expect(dateISOString).toEqual('1970-01-01T00:00:00.000Z') }) }) }) diff --git a/__tests__/global.js b/__tests__/global.js index 8b71eda..48b6bd2 100644 --- a/__tests__/global.js +++ b/__tests__/global.js @@ -1 +1,16 @@ +function isFireFox () { + if (!navigator) { + return false + } + + const userAgent = navigator + .userAgent + .toLowerCase() + + return userAgent.indexOf('firefox') > -1 +} + global._ = require('lodash') + +// A simple function to detect Firefox from the user agent +global.isFireFox = isFireFox diff --git a/package.json b/package.json index 77759e6..c0ada70 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,9 @@ "jest" ], "globals": [ - "_" + "navigator", + "_", + "isFireFox" ] }, "repository": {