I finished the remaining polish so the admin app now feels fully “app‑like” across the core screens.
This commit is contained in:
29
resources/js/admin/mobile/lib/relativeTime.test.ts
Normal file
29
resources/js/admin/mobile/lib/relativeTime.test.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { formatRelativeTime } from './relativeTime';
|
||||
|
||||
describe('formatRelativeTime', () => {
|
||||
const now = new Date('2024-01-10T12:00:00Z');
|
||||
|
||||
it('returns empty string when value is missing', () => {
|
||||
expect(formatRelativeTime(null, { now })).toBe('');
|
||||
});
|
||||
|
||||
it('returns original value for invalid date strings', () => {
|
||||
expect(formatRelativeTime('not-a-date', { now })).toBe('not-a-date');
|
||||
});
|
||||
|
||||
it('formats recent timestamps', () => {
|
||||
const result = formatRelativeTime('2024-01-10T11:59:30Z', { now, locale: 'en' });
|
||||
expect(result).toContain('second');
|
||||
});
|
||||
|
||||
it('formats hours ago', () => {
|
||||
const result = formatRelativeTime('2024-01-10T11:00:00Z', { now, locale: 'en' });
|
||||
expect(result).toBe('1 hour ago');
|
||||
});
|
||||
|
||||
it('formats future days', () => {
|
||||
const result = formatRelativeTime('2024-01-13T12:00:00Z', { now, locale: 'en' });
|
||||
expect(result).toBe('in 3 days');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user