Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
tan75 authored and kossnocorp committed Mar 12, 2024
1 parent 798d6e9 commit fceef14
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/constructFrom/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,13 @@ describe('constructFrom', () => {
assert.strictEqual(result.constructor, referenceDate.constructor)
})

it('should create a new custom Date instance using a number as the reference date', () => {
class CustomDate extends Date {}
const referenceDate = new CustomDate(1635158400000) // October 25, 2023
const value = new CustomDate('2023-10-26T12:00:00')
it('should create a new Date instance using numbers as both referenceDate and value', () => {
const referenceDate = 1635158400000 // October 25, 2023
const value = 1635244800000 // October 26, 2023

const result = constructFrom(referenceDate, value)

assert.ok(result instanceof CustomDate)
assert.deepStrictEqual(result, value)
assert.strictEqual(result.constructor, CustomDate)
assert.ok(result instanceof Date)
assert.deepStrictEqual(result.getTime(), value)
})
})

0 comments on commit fceef14

Please sign in to comment.