jan/web/utils/datetime.test.ts
Louis 846efb3126
test: add core modules test cases (#3498)
* chore: add core module test cases

* chore: fix tests

* chore: add code coverage report

* chore: split coverage step

* chore: split coverage step

* Update jan-electron-linter-and-test.yml

* Update jan-electron-linter-and-test.yml

* Update jan-electron-linter-and-test.yml

* chore: update tests

* chore: add web utils test cases

* chore: add restful and helper tests

* chore: add tests
2024-09-06 11:14:28 +07:00

28 lines
701 B
TypeScript

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, {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: true,
});
expect(displayDate(timestamp)).toBe(expectedTime);
});
test('should return N/A for undefined timestamp', () => {
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);
});