mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
add tests for date.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import type { WeekDay } from '$lib/helpers/date';
|
||||
import {
|
||||
toLocaleDate,
|
||||
toLocaleDateTime,
|
||||
@@ -6,7 +7,9 @@ import {
|
||||
isValidDate,
|
||||
diffDays,
|
||||
toLocaleDateISO,
|
||||
toLocaleTimeISO
|
||||
toLocaleTimeISO,
|
||||
utcHourToLocaleHour,
|
||||
utcWeekDayToLocaleWeekDay
|
||||
} from '$lib/helpers/date';
|
||||
|
||||
describe('local date', () => {
|
||||
@@ -121,3 +124,35 @@ describe('diff days', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('utc hour to local hour', () => {
|
||||
const entries: Array<[string, string]> = [
|
||||
['09:00', '04:00'],
|
||||
['10:45', '05:45'],
|
||||
['11:59', '06:59'],
|
||||
['17:00', '12:00'],
|
||||
['22:36', '17:36']
|
||||
];
|
||||
|
||||
entries.forEach(([value, expected]) => {
|
||||
it(value, () => {
|
||||
expect(utcHourToLocaleHour(value)).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('utc week day to local week day', () => {
|
||||
const entries: Array<[WeekDay, string, string]> = [
|
||||
['Sunday', '00:00', 'Sat'],
|
||||
['Sunday', '22:00', 'Sun'],
|
||||
['Wednesday', '13:00', 'Wed'],
|
||||
['Friday', '23:59', 'Fri'],
|
||||
['Saturday', '10:00', 'Sat']
|
||||
];
|
||||
|
||||
entries.forEach(([weekDay, utcTimeString, expected]) => {
|
||||
it(`${weekDay} ${utcTimeString}`, () => {
|
||||
expect(utcWeekDayToLocaleWeekDay(weekDay, utcTimeString)).toBe(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user