-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix format (apparently autoformat don't work on test file?)
- Loading branch information
1 parent
afd71a8
commit 25767ea
Showing
1 changed file
with
20 additions
and
20 deletions.
There are no files selected for viewing
40 changes: 20 additions & 20 deletions
40
packages/components/src/utils/__tests__/getParsedData.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
import { describe, expect, it } from "vitest" | ||
|
||
import { getParsedDate } from '../getParsedDate' | ||
import { getParsedDate } from "../getParsedDate" | ||
|
||
describe('getParsedDate', () => { | ||
it('parses dd/MM/yyyy format correctly', () => { | ||
const result = getParsedDate('25/12/2023') | ||
describe("getParsedDate", () => { | ||
it("parses dd/MM/yyyy format correctly", () => { | ||
const result = getParsedDate("25/12/2023") | ||
expect(result).toStrictEqual(new Date(2023, 11, 25)) | ||
}) | ||
|
||
it('parses d MMM yyyy format correctly', () => { | ||
const result = getParsedDate('5 Jan 2023') | ||
it("parses d MMM yyyy format correctly", () => { | ||
const result = getParsedDate("5 Jan 2023") | ||
expect(result).toStrictEqual(new Date(2023, 0, 5)) | ||
}) | ||
|
||
it('parses d MMMM yyyy format correctly', () => { | ||
const result = getParsedDate('15 March 2023') | ||
it("parses d MMMM yyyy format correctly", () => { | ||
const result = getParsedDate("15 March 2023") | ||
expect(result).toStrictEqual(new Date(2023, 2, 15)) | ||
}) | ||
|
||
it('parses dd MMM yyyy format correctly', () => { | ||
const result = getParsedDate('05 Apr 2023') | ||
it("parses dd MMM yyyy format correctly", () => { | ||
const result = getParsedDate("05 Apr 2023") | ||
expect(result).toStrictEqual(new Date(2023, 3, 5)) | ||
}) | ||
|
||
it('parses dd MMMM yyyy format correctly', () => { | ||
const result = getParsedDate('30 November 2023') | ||
it("parses dd MMMM yyyy format correctly", () => { | ||
const result = getParsedDate("30 November 2023") | ||
expect(result).toStrictEqual(new Date(2023, 10, 30)) | ||
}) | ||
|
||
it('parses yyyy-MM-dd format correctly', () => { | ||
const result = getParsedDate('2023-06-15') | ||
it("parses yyyy-MM-dd format correctly", () => { | ||
const result = getParsedDate("2023-06-15") | ||
expect(result).toStrictEqual(new Date(2023, 5, 15)) | ||
}) | ||
|
||
it('parses ISO 8601 format correctly', () => { | ||
it("parses ISO 8601 format correctly", () => { | ||
const result = getParsedDate("2023-07-20T14:30:45.123Z") | ||
expect(result).toStrictEqual(new Date(2023, 6, 20, 14, 30, 45, 123)) | ||
}) | ||
|
||
it('returns current date for unsupported format', () => { | ||
const result = getParsedDate('unsupported format') | ||
it("returns current date for unsupported format", () => { | ||
const result = getParsedDate("unsupported format") | ||
expect(result).toBeInstanceOf(Date) | ||
expect(result.getTime()).toBeCloseTo(new Date().getTime(), -3) // Allow 1 second difference | ||
}) | ||
|
||
it('returns current date for invalid date', () => { | ||
const result = getParsedDate('32/13/2023') // Invalid date | ||
it("returns current date for invalid date", () => { | ||
const result = getParsedDate("32/13/2023") // Invalid date | ||
expect(result).toBeInstanceOf(Date) | ||
expect(result.getTime()).toBeCloseTo(new Date().getTime(), -3) // Allow 1 second difference | ||
}) | ||
}) | ||
}) |