fix date type for ISODate

This commit is contained in:
Julien Calixte
2023-04-10 16:15:57 +02:00
parent f8a7231cd0
commit 531a05be26
2 changed files with 6 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
import type { Taskable } from '@/modules/task/interfaces/taskable' import type { Taskable } from '@/modules/task/interfaces/taskable'
import { createStepFixture } from '@/modules/task/models/step.fixture' import { createStepFixture } from '@/modules/task/models/step.fixture'
import { Task } from '@/modules/task/models/task' import { Task } from '@/modules/task/models/task'
import { toISODate } from '@/shared/types/date'
import { faker } from '@faker-js/faker' import { faker } from '@faker-js/faker'
import { describe, expect, it } from 'vitest' import { describe, expect, it } from 'vitest'
@@ -16,7 +17,7 @@ describe('Task', () => {
it('allows a new task from a taskable object', () => { it('allows a new task from a taskable object', () => {
const taskable: Taskable = { const taskable: Taskable = {
id: faker.datatype.uuid(), id: faker.datatype.uuid(),
date: faker.date.recent(), date: toISODate(faker.date.recent()),
title: faker.animal.lion(), title: faker.animal.lion(),
link: faker.internet.url(), link: faker.internet.url(),
steps: [createStepFixture()] steps: [createStepFixture()]

View File

@@ -1,3 +1,5 @@
export type ISODate = string type Brand<K, T> = K & { __brand: T }
export const toISODate = (date: Date): ISODate => date.toISOString() export type ISODate = Brand<string, 'ISODate'>
export const toISODate = (date: Date): ISODate => date.toISOString() as ISODate