From 7952eda8d267f4610597c0e51d713e953febb958 Mon Sep 17 00:00:00 2001 From: Adam Gibbons Date: Mon, 24 Aug 2020 22:47:34 -0600 Subject: [PATCH] remove moment from remaining tests --- package-lock.json | 75 ++++++++++--------- package.json | 2 +- test/pipeline/format.spec.js | 12 +-- test/utils/format-date.spec.js | 5 +- test/utils/format-local-date-as-local.spec.js | 4 +- test/utils/format-utc-date-as-utc.spec.js | 4 +- 6 files changed, 54 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index cea719c..b999f2b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ics", - "version": "2.22.1", + "version": "2.24.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -25,16 +25,16 @@ } }, "@babel/core": { - "version": "7.11.1", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.1.tgz", - "integrity": "sha512-XqF7F6FWQdKGGWAzGELL+aCO1p+lRY5Tj5/tbT3St1G8NaH70jhhDIKknIZaDans0OQBG5wRAldROLHSt44BgQ==", + "version": "7.11.4", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.11.4.tgz", + "integrity": "sha512-5deljj5HlqRXN+5oJTY7Zs37iH3z3b++KjiKtIsJy1NrjOOVSEaJHEetLBhyu0aQOSNNZ/0IuEAan9GzRuDXHg==", "dev": true, "requires": { "@babel/code-frame": "^7.10.4", - "@babel/generator": "^7.11.0", + "@babel/generator": "^7.11.4", "@babel/helper-module-transforms": "^7.11.0", "@babel/helpers": "^7.10.4", - "@babel/parser": "^7.11.1", + "@babel/parser": "^7.11.4", "@babel/template": "^7.10.4", "@babel/traverse": "^7.11.0", "@babel/types": "^7.11.0", @@ -49,9 +49,9 @@ } }, "@babel/generator": { - "version": "7.11.0", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.11.0.tgz", - "integrity": "sha512-fEm3Uzw7Mc9Xi//qU20cBKatTfs2aOtKqmvy/Vm7RkJEGFQ4xc9myCfbXxqK//ZS8MR/ciOHw6meGASJuKmDfQ==", + "version": "7.11.4", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.11.4.tgz", + "integrity": "sha512-Rn26vueFx0eOoz7iifCN2UHT6rGtnkSGWSoDRIy8jZN3B91PzeSULbswfLoOWuTuAcNwpG/mxy+uCTDnZ9Mp1g==", "dev": true, "requires": { "@babel/types": "^7.11.0", @@ -128,12 +128,11 @@ } }, "@babel/helper-explode-assignable-expression": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.10.4.tgz", - "integrity": "sha512-4K71RyRQNPRrR85sr5QY4X3VwG4wtVoXZB9+L3r1Gp38DhELyHCtovqydRi7c1Ovb17eRGiQ/FD5s8JdU0Uy5A==", + "version": "7.11.4", + "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.11.4.tgz", + "integrity": "sha512-ux9hm3zR4WV1Y3xXxXkdG/0gxF9nvI0YVmKVhvK9AfMoaQkemL3sJpXw+Xbz65azo8qJiEz2XVDUpK3KYhH3ZQ==", "dev": true, "requires": { - "@babel/traverse": "^7.10.4", "@babel/types": "^7.10.4" } }, @@ -224,15 +223,14 @@ } }, "@babel/helper-remap-async-to-generator": { - "version": "7.10.4", - "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.10.4.tgz", - "integrity": "sha512-86Lsr6NNw3qTNl+TBcF1oRZMaVzJtbWTyTko+CQL/tvNvcGYEFKbLXDPxtW0HKk3McNOk4KzY55itGWCAGK5tg==", + "version": "7.11.4", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.11.4.tgz", + "integrity": "sha512-tR5vJ/vBa9wFy3m5LLv2faapJLnDFxNWff2SAYkSE4rLUdbp7CdObYFgI7wK4T/Mj4UzpjPwzR8Pzmr5m7MHGA==", "dev": true, "requires": { "@babel/helper-annotate-as-pure": "^7.10.4", "@babel/helper-wrap-function": "^7.10.4", "@babel/template": "^7.10.4", - "@babel/traverse": "^7.10.4", "@babel/types": "^7.10.4" } }, @@ -317,9 +315,9 @@ } }, "@babel/parser": { - "version": "7.11.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.3.tgz", - "integrity": "sha512-REo8xv7+sDxkKvoxEywIdsNFiZLybwdI7hcT5uEPyQrSMB4YQ973BfC9OOrD/81MaIjh6UxdulIQXkjmiH3PcA==", + "version": "7.11.4", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.11.4.tgz", + "integrity": "sha512-MggwidiH+E9j5Sh8pbrX5sJvMcsqS5o+7iB42M9/k0CD63MjYbdP4nhSh7uB5wnv2/RVzTZFTxzF/kIa5mrCqA==", "dev": true }, "@babel/plugin-proposal-async-generator-functions": { @@ -1504,9 +1502,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001114", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001114.tgz", - "integrity": "sha512-ml/zTsfNBM+T1+mjglWRPgVsu2L76GAaADKX5f4t0pbhttEp0WMawJsHDYlFkVZkoA+89uvBRrVrEE4oqenzXQ==", + "version": "1.0.30001117", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001117.tgz", + "integrity": "sha512-4tY0Fatzdx59kYjQs+bNxUwZB03ZEBgVmJ1UkFPz/Q8OLiUUbjct2EdpnXj0fvFTPej2EkbPIG0w8BWsjAyk1Q==", "dev": true }, "chai": { @@ -1761,9 +1759,9 @@ } }, "dayjs": { - "version": "1.8.33", - "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.33.tgz", - "integrity": "sha512-881TDLZCdpJFKbraWRHcUG8zfMLLX400ENf9rFZDuWc5zYMss6xifo2PhlDX0ftOmR2NRmaIY47bAa4gKQfXqw==" + "version": "1.8.34", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.34.tgz", + "integrity": "sha512-Olb+E6EoMvdPmAMq2QoucuyZycKHjTlBXmRx8Ada+wGtq4SIXuDCdtoaX4KkK0yjf1fJLnwXQURr8gQKWKaybw==" }, "debug": { "version": "4.1.1", @@ -1903,9 +1901,9 @@ } }, "electron-to-chromium": { - "version": "1.3.533", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.533.tgz", - "integrity": "sha512-YqAL+NXOzjBnpY+dcOKDlZybJDCOzgsq4koW3fvyty/ldTmsb4QazZpOWmVvZ2m0t5jbBf7L0lIGU3BUipwG+A==", + "version": "1.3.545", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.545.tgz", + "integrity": "sha512-+0R/i17u5E1cwF3g0W8Niq3UUKTUMyyT4kLkutZUHG8mDNvFsAckK3HIanzGVtixe3b6rknD8k7gHiR6nKFkgg==", "dev": true }, "emoji-regex": { @@ -2099,9 +2097,9 @@ }, "dependencies": { "type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", - "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.1.0.tgz", + "integrity": "sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA==", "dev": true } } @@ -2210,6 +2208,12 @@ "time-stamp": "^1.0.0" } }, + "fast-levenshtein": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-1.1.4.tgz", + "integrity": "sha1-5qdUzI8V5YmHqpy9J69m/W9OWvk=", + "dev": true + }, "file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -4666,9 +4670,9 @@ "dev": true }, "undertaker": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.2.1.tgz", - "integrity": "sha512-71WxIzDkgYk9ZS+spIB8iZXchFhAdEo2YU8xYqBYJ39DIUIqziK78ftm26eecoIY49X0J2MLhG4hr18Yp6/CMA==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/undertaker/-/undertaker-1.3.0.tgz", + "integrity": "sha512-/RXwi5m/Mu3H6IHQGww3GNt1PNXlbeCuclF2QYR14L/2CHPz3DFZkvB5hZ0N/QUkiXWCACML2jXViIQEQc2MLg==", "dev": true, "requires": { "arr-flatten": "^1.0.1", @@ -4676,6 +4680,7 @@ "bach": "^1.0.0", "collection-map": "^1.0.0", "es6-weak-map": "^2.0.1", + "fast-levenshtein": "^1.0.0", "last-run": "^1.1.0", "object.defaults": "^1.0.0", "object.reduce": "^1.0.0", diff --git a/package.json b/package.json index 6b1ef36..59860f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ics", - "version": "2.23.0", + "version": "2.24.0", "description": "iCal (ics) file generator", "main": "index.js", "types": "index.d.ts", diff --git a/test/pipeline/format.spec.js b/test/pipeline/format.spec.js index 9ac1f79..baa4768 100644 --- a/test/pipeline/format.spec.js +++ b/test/pipeline/format.spec.js @@ -1,4 +1,4 @@ -import moment from 'moment'; +import dayjs from 'dayjs'; import { expect } from 'chai' import { formatEvent, @@ -39,13 +39,13 @@ describe('pipeline.formatEvent', () => { it('writes a start date-time, taking the given date as local by default and outputting is as UTC by default', () => { const event = buildEvent({ start: [2017, 5, 15, 10, 0] }) const formattedEvent = formatEvent(event) - const now = moment([2017, 5 - 1, 15, 10, 0]).utc().format('YYYYMMDDTHHmm00') + const now = dayjs(new Date(2017, 5 - 1, 15, 10, 0)).utc().format('YYYYMMDDTHHmm00') expect(formattedEvent).to.contain('DTSTART:'+now+'Z') }) it('writes a start date-time, taking the given date as local by default and outputting is as UTC if requested', () => { const event = buildEvent({ start: [2017, 5, 15, 10, 0], startOutputType: 'utc' }) const formattedEvent = formatEvent(event) - const now = moment([2017, 5 - 1, 15, 10, 0]).utc().format('YYYYMMDDTHHmm00') + const now = dayjs(new Date(2017, 5 - 1, 15, 10, 0)).utc().format('YYYYMMDDTHHmm00') expect(formattedEvent).to.contain('DTSTART:'+now+'Z') }) it('writes a start date-time, taking the given date as local by default and outputting is as Local (floating) if requested', () => { @@ -57,13 +57,13 @@ describe('pipeline.formatEvent', () => { it('writes a start date-time, taking the given date as local if requested and outputting is as UTC by default', () => { const event = buildEvent({ start: [2017, 5, 15, 10, 0], startInputType: 'local' }) const formattedEvent = formatEvent(event) - const now = moment([2017, 5 - 1, 15, 10, 0]).utc().format('YYYYMMDDTHHmm00') + const now = dayjs(new Date(2017, 5 - 1, 15, 10, 0)).utc().format('YYYYMMDDTHHmm00') expect(formattedEvent).to.contain('DTSTART:'+now+'Z') }) it('writes a start date-time, taking the given date as local if requested and outputting is as UTC if requested', () => { const event = buildEvent({ start: [2017, 5, 15, 10, 0], startInputType: 'local', startOutputType: 'utc' }) const formattedEvent = formatEvent(event) - const now = moment([2017, 5 - 1, 15, 10, 0]).utc().format('YYYYMMDDTHHmm00') + const now = dayjs(new Date(2017, 5 - 1, 15, 10, 0)).utc().format('YYYYMMDDTHHmm00') expect(formattedEvent).to.contain('DTSTART:'+now+'Z') }) it('writes a start date-time, taking the given date as local if requested and outputting is as Local (floating) if requested', () => { @@ -85,7 +85,7 @@ describe('pipeline.formatEvent', () => { it('writes a start date-time, taking the given date as UTC if requested and outputting is as Local (floating) if requested', () => { const event = buildEvent({ start: [2017, 5, 15, 10, 0], startInputType: 'utc', startOutputType: 'local' }) const formattedEvent = formatEvent(event) - const now = moment.utc([2017, 5 - 1, 15, 10, 0]).format('YYYYMMDDTHHmm00') + const now = dayjs(new Date(2017, 5 - 1, 15, 10, 0)).format('YYYYMMDDTHHmm00') expect(formattedEvent).to.contain('DTSTART:'+now) expect(formattedEvent).to.not.contain('DTSTART:'+now+'Z') }) diff --git a/test/utils/format-date.spec.js b/test/utils/format-date.spec.js index 2964b67..604eab2 100644 --- a/test/utils/format-date.spec.js +++ b/test/utils/format-date.spec.js @@ -1,10 +1,11 @@ -import moment from 'moment' +import dayjs from 'dayjs' + import { formatDate } from '../../src/utils' import { expect } from 'chai' describe('utils.formatDate', () => { it('defaults to local time input and UTC time output when no type passed', () => { - const now = moment([2017, 7-1, 16, 22, 30]).utc().format('YYYYMMDDTHHmm00') + const now = dayjs(new Date(2017, 7-1, 16, 22, 30)).utc().format('YYYYMMDDTHHmm00') expect(formatDate([2017, 7, 16, 22, 30])).to.equal(now+'Z') }) it('sets a local (i.e. floating) time when specified', () => { diff --git a/test/utils/format-local-date-as-local.spec.js b/test/utils/format-local-date-as-local.spec.js index 659d3a5..055fecf 100644 --- a/test/utils/format-local-date-as-local.spec.js +++ b/test/utils/format-local-date-as-local.spec.js @@ -1,6 +1,6 @@ // FORM #1: DATE WITH LOCAL TIME -import moment from 'moment' +import dayjs from 'dayjs' import { formatLocalDateAsLocal } from '../../src/utils' import { expect } from 'chai' @@ -9,7 +9,7 @@ describe('utils.formatLocalDateAsLocal', () => { expect(formatLocalDateAsLocal).to.exist }) it('sets a DATE-TIME value to NOW when passed nothing', () => { - const now = moment().format('YYYYMMDDTHHmmss') + const now = dayjs().format('YYYYMMDDTHHmmss') expect(formatLocalDateAsLocal()).to.equal(now) }) it('sets a DATE-TIME value when passed args', () => { diff --git a/test/utils/format-utc-date-as-utc.spec.js b/test/utils/format-utc-date-as-utc.spec.js index 3ee08d2..1b3729a 100644 --- a/test/utils/format-utc-date-as-utc.spec.js +++ b/test/utils/format-utc-date-as-utc.spec.js @@ -1,10 +1,10 @@ -import moment from 'moment' +import dayjs from 'dayjs' import { formatUTCDateAsUTC } from '../../src/utils' import { expect } from 'chai' describe('utils.formatUTCDateAsUTC', () => { it('defaults to NOW in UTC date-time when no args passed', () => { - const now = moment().utc().format('YYYYMMDDTHHmm00') + 'Z' + const now = dayjs().utc().format('YYYYMMDDTHHmm00') + 'Z' expect(now).to.equal(formatUTCDateAsUTC()) })