From beaf8114a7c39a11178ac9cb7d34e314c701bb69 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 17 Dec 2024 18:11:07 +0700 Subject: [PATCH] test: update test cases --- web/utils/datetime.test.ts | 39 ++++++++++++++++--------------- web/utils/threadMessageBuilder.ts | 4 ++-- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/web/utils/datetime.test.ts b/web/utils/datetime.test.ts index 75bdb1f8f7..e7e00ada98 100644 --- a/web/utils/datetime.test.ts +++ b/web/utils/datetime.test.ts @@ -1,27 +1,28 @@ +import { displayDate } from './datetime' +import { isToday } from './datetime' -import { displayDate } from './datetime'; -import { isToday } from './datetime'; - -test('should return only time for today\'s timestamp', () => { - const today = new Date(); - const timestamp = today.getTime(); - const expectedTime = today.toLocaleTimeString(undefined, { +test("should return only time for today's timestamp", () => { + const today = new Date() + const timestamp = today.getTime() + const expectedTime = `${today.toLocaleDateString(undefined, { + day: '2-digit', + month: 'short', + year: 'numeric', + })}, ${today.toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true, - }); - expect(displayDate(timestamp)).toBe(expectedTime); -}); - + })}` + expect(displayDate(timestamp / 1000)).toBe(expectedTime) +}) test('should return N/A for undefined timestamp', () => { - expect(displayDate()).toBe('N/A'); -}); - + expect(displayDate()).toBe('N/A') +}) -test('should return true for today\'s timestamp', () => { - const today = new Date(); - const timestamp = today.setHours(0, 0, 0, 0); - expect(isToday(timestamp)).toBe(true); -}); +test("should return true for today's timestamp", () => { + const today = new Date() + const timestamp = today.setHours(0, 0, 0, 0) + expect(isToday(timestamp)).toBe(true) +}) diff --git a/web/utils/threadMessageBuilder.ts b/web/utils/threadMessageBuilder.ts index d1aac2f842..d10ef03c40 100644 --- a/web/utils/threadMessageBuilder.ts +++ b/web/utils/threadMessageBuilder.ts @@ -29,8 +29,8 @@ export class ThreadMessageBuilder { attachments: this.attachments, role: ChatCompletionRole.User, status: MessageStatus.Ready, - created: timestamp, - updated: timestamp, + created_at: timestamp, + completed_at: timestamp, object: 'thread.message', content: this.content, }