forked from cardosofelipe/fast-next-template
- Replaced static paths with dynamic locale subpaths (`/[locale]/*`) in imports, URLs, and assertions across tests. - Updated `next-intl` mocks for improved compatibility with `locale`-aware components. - Standardized `page.goto` and navigation tests with `/en` as the base locale for consistency.
27 lines
741 B
TypeScript
27 lines
741 B
TypeScript
/**
|
|
* Tests for Settings Index Page
|
|
* Verifies redirect behavior
|
|
*/
|
|
|
|
import { redirect } from 'next/navigation';
|
|
import SettingsPage from '@/app/[locale]/(authenticated)/settings/page';
|
|
|
|
// Mock Next.js navigation - redirect throws to interrupt execution
|
|
jest.mock('next/navigation', () => ({
|
|
redirect: jest.fn(() => {
|
|
throw new Error('NEXT_REDIRECT');
|
|
}),
|
|
}));
|
|
|
|
describe('SettingsPage', () => {
|
|
beforeEach(() => {
|
|
jest.clearAllMocks();
|
|
});
|
|
|
|
it('redirects to /settings/profile with locale prefix', async () => {
|
|
const params = Promise.resolve({ locale: 'en' });
|
|
await expect(SettingsPage({ params })).rejects.toThrow('NEXT_REDIRECT');
|
|
expect(redirect).toHaveBeenCalledWith('/en/settings/profile');
|
|
});
|
|
});
|