Skip to content

Commit

Permalink
remove moment from remaining tests
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgibbons committed Aug 25, 2020
1 parent 18031ed commit 7952eda
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 48 deletions.
75 changes: 40 additions & 35 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 6 additions & 6 deletions test/pipeline/format.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import moment from 'moment';
import dayjs from 'dayjs';
import { expect } from 'chai'
import {
formatEvent,
Expand Down Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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')
})
Expand Down
5 changes: 3 additions & 2 deletions test/utils/format-date.spec.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/utils/format-local-date-as-local.spec.js
Original file line number Diff line number Diff line change
@@ -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'

Expand All @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/utils/format-utc-date-as-utc.spec.js
Original file line number Diff line number Diff line change
@@ -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())
})

Expand Down

0 comments on commit 7952eda

Please sign in to comment.