Skip to content

Commit

Permalink
test: update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Dec 17, 2024
1 parent 8613e35 commit beaf811
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
39 changes: 20 additions & 19 deletions web/utils/datetime.test.ts
Original file line number Diff line number Diff line change
@@ -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)
})
4 changes: 2 additions & 2 deletions web/utils/threadMessageBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit beaf811

Please sign in to comment.