Add global navigation search, cancellation policies, and UI improvements
- Add global search in top bar for navigating to dashboard pages - Add cancellation policy settings (window hours, late fee, deposit refund) - Display booking policies on customer confirmation page - Filter API tokens by sandbox/live mode - Widen settings layout and full-width site builder - Add help documentation search with OpenAI integration - Add blocked time ranges API for calendar visualization - Update business hours settings with holiday management 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
113
frontend/src/hooks/__tests__/useDateFnsLocale.test.ts
Normal file
113
frontend/src/hooks/__tests__/useDateFnsLocale.test.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { useDateFnsLocale } from '../useDateFnsLocale';
|
||||
import { enUS, de, es, fr } from 'date-fns/locale';
|
||||
|
||||
// Mock react-i18next
|
||||
vi.mock('react-i18next', () => ({
|
||||
useTranslation: vi.fn(),
|
||||
}));
|
||||
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
describe('useDateFnsLocale', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('returns English locale by default', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: 'en' },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(enUS);
|
||||
});
|
||||
|
||||
it('returns German locale for de', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: 'de' },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(de);
|
||||
});
|
||||
|
||||
it('returns Spanish locale for es', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: 'es' },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(es);
|
||||
});
|
||||
|
||||
it('returns French locale for fr', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: 'fr' },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(fr);
|
||||
});
|
||||
|
||||
it('handles language with region code (en-US)', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: 'en-US' },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(enUS);
|
||||
});
|
||||
|
||||
it('handles language with region code (de-DE)', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: 'de-DE' },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(de);
|
||||
});
|
||||
|
||||
it('returns English locale for unknown language', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: 'xx' },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(enUS);
|
||||
});
|
||||
|
||||
it('returns English locale when language is undefined', () => {
|
||||
vi.mocked(useTranslation).mockReturnValue({
|
||||
i18n: { language: undefined },
|
||||
t: vi.fn(),
|
||||
ready: true,
|
||||
} as ReturnType<typeof useTranslation>);
|
||||
|
||||
const { result } = renderHook(() => useDateFnsLocale());
|
||||
|
||||
expect(result.current).toBe(enUS);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user