@@ -13,7 +13,7 @@ const NoticesProvider = ({ children }) => {
|
||||
useEffect(async () => {
|
||||
if (getConfig().ENABLE_NOTICES) {
|
||||
const data = await getNotices();
|
||||
if (data && data.results) {
|
||||
if (data && data.results && data.results.length > 0) {
|
||||
const { results } = data;
|
||||
setIsRedirected(true);
|
||||
window.location.replace(`${results[0]}?next=${window.location.href}`);
|
||||
|
||||
@@ -44,7 +44,7 @@ describe('NoticesProvider', () => {
|
||||
delete window.location;
|
||||
window.location = { replace: jest.fn() };
|
||||
process.env.ENABLE_NOTICES = true;
|
||||
await act(() => buildAndRender());
|
||||
await act(async () => buildAndRender());
|
||||
expect(window.location.replace).toHaveBeenCalledWith(`${redirectUrl}?next=${window.location.href}`);
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('NoticesProvider', () => {
|
||||
delete window.location;
|
||||
window.location = { replace: jest.fn() };
|
||||
process.env.ENABLE_NOTICES = true;
|
||||
await act(() => buildAndRender());
|
||||
await act(async () => buildAndRender());
|
||||
expect(window.location.replace).toHaveBeenCalledTimes(0);
|
||||
expect(window.location.toString() === 'http://localhost/');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user