From 511dc7c2dff5ab90f10d762c86fedb92b4479df0 Mon Sep 17 00:00:00 2001 From: Poovamraj T T Date: Tue, 28 Nov 2023 11:52:16 +0100 Subject: [PATCH] Fix unit test case --- src/webauth/__tests__/agent.spec.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/webauth/__tests__/agent.spec.js b/src/webauth/__tests__/agent.spec.js index 53ee5a82..e85ab486 100644 --- a/src/webauth/__tests__/agent.spec.js +++ b/src/webauth/__tests__/agent.spec.js @@ -248,8 +248,15 @@ describe('Agent', () => { jest .spyOn(Linking, 'addEventListener') .mockReturnValueOnce(mockSubscription); - await agent.login({}, { safariViewControllerPresentationStyle: 0 }); - expect(Linking.addEventListener).toHaveBeenCalledTimes(1); + jest + .spyOn(nativeUtils, '_ensureNativeModuleIsInitialized') + .mockImplementationOnce(() => { + throw Error('123123'); + }); + try { + await agent.login({}, {}); + } catch (e) {} + expect(Linking.addEventListener).toHaveBeenCalledTimes(0); expect(mockSubscription.remove).toHaveBeenCalledTimes(0); }); });