Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit ee433f5

Browse files
Hubert KosterHubert Koster
authored andcommitted
chore: fixing test
1 parent a904a90 commit ee433f5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/features/Apiexplorer/SubscribeRenderer/__tests__/SubscribeRenderer.test.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ describe('SubscribeRenderer', () => {
204204
await userEvent.click(button);
205205
expect(mockUnsubscribe).toBeCalledTimes(1);
206206
});
207-
208207
it('should call unsubscribe when unmounting the component', async () => {
209208
const { unmount } = render(<SubscribeRenderer name='ticks' auth={1} reqData={request_data} />);
210209
unmount();
@@ -214,27 +213,26 @@ describe('SubscribeRenderer', () => {
214213
cleanup();
215214
jest.clearAllMocks();
216215

217-
const setToggleModal = jest.fn();
218-
jest.spyOn(React, 'useState').mockReturnValue([false, setToggleModal]);
219216
mockUseAuthContext.mockImplementation(() => ({
220217
is_logged_in: false,
221-
is_authorized: false,
218+
is_authorized: true,
222219
}));
223220
mockUseSubscription.mockImplementation(() => ({
224221
subscribe: mockSubscribe,
225222
unsubscribe: mockUnsubscribe,
226223
error: { code: 'AuthorizationRequired' },
227224
full_response: {
228-
tick: 1,
229-
echo_req: { tick: 1 },
225+
app_list: 1,
226+
echo_req: { app_list: 1 },
230227
},
231228
}));
232229

233230
render(<SubscribeRenderer name='ticks' auth={1} reqData={request_data} />);
234-
const button = await screen.findByRole('button', { name: /Send Request/i });
235-
await userEvent.click(button);
231+
const login_dialog = await screen.findByText(
232+
/This API call must be authorised because it requires access to your account information./i,
233+
);
236234
await waitFor(() => {
237-
expect(setToggleModal).toHaveBeenCalled();
235+
expect(login_dialog).toBeVisible();
238236
});
239237
});
240238
});

0 commit comments

Comments
 (0)