mirror of
https://github.com/strapi/strapi.git
synced 2025-09-22 14:59:07 +00:00
Add a test case for PrivateRoute
This commit is contained in:
parent
785c4e862e
commit
b03e8e4adb
@ -54,7 +54,7 @@ describe('PrivateRoute', () => {
|
||||
expect(screen.getByText('Please login')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Visit /settings/application-infos
|
||||
// Visit /settings/application-infos (no search params)
|
||||
history.push('/settings/application-infos');
|
||||
// Should redirected to `/auth/login` and preserve the `/settings/application-infos` path
|
||||
await waitFor(() => {
|
||||
@ -65,5 +65,16 @@ describe('PrivateRoute', () => {
|
||||
);
|
||||
expect(screen.getByText('Please login')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Visit /settings/application-infos (have search params)
|
||||
history.push('/settings/application-infos?hello=world');
|
||||
await waitFor(() => {
|
||||
expect(history.location.pathname).toBe('/auth/login');
|
||||
// Should preserve search params
|
||||
expect(history.location.search).toBe(
|
||||
`?redirectTo=${encodeURIComponent('/settings/application-infos?hello=world')}`
|
||||
);
|
||||
expect(screen.getByText('Please login')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user