Skip to content

Commit fe69f3e

Browse files
test(directLoginAction): verify all four args bridge to native
Covers the signature-alignment fix: the JS directLoginAction forwards type, data, ephemeralSession and additionalQueryParams to the native module, and defaults ephemeralSession to true when omitted.
1 parent f8f1aea commit fe69f3e

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

src/__tests__/index.test.tsx

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { NativeModules } from 'react-native';
2-
import { openAdminPortal } from '../FronteggNative';
2+
import { directLoginAction, openAdminPortal } from '../FronteggNative';
33

44
jest.mock('react-native', () => ({
55
NativeModules: {
66
FronteggRN: {
77
openAdminPortal: jest.fn(() => Promise.resolve(null)),
8+
directLoginAction: jest.fn(() => Promise.resolve()),
89
subscribe: jest.fn(),
910
},
1011
},
@@ -22,3 +23,30 @@ describe('openAdminPortal', () => {
2223
expect(NativeModules.FronteggRN.openAdminPortal).toHaveBeenCalled();
2324
});
2425
});
26+
27+
describe('directLoginAction', () => {
28+
beforeEach(() => {
29+
(NativeModules.FronteggRN.directLoginAction as jest.Mock).mockClear();
30+
});
31+
32+
it('bridges type, data, ephemeralSession and additionalQueryParams to the native module', async () => {
33+
const params = { prompt: 'consent', foo: 'bar' };
34+
await directLoginAction('social-login', 'google', false, params);
35+
expect(NativeModules.FronteggRN.directLoginAction).toHaveBeenCalledWith(
36+
'social-login',
37+
'google',
38+
false,
39+
params
40+
);
41+
});
42+
43+
it('defaults ephemeralSession to true and forwards an undefined additionalQueryParams', async () => {
44+
await directLoginAction('social-login', 'google');
45+
expect(NativeModules.FronteggRN.directLoginAction).toHaveBeenCalledWith(
46+
'social-login',
47+
'google',
48+
true,
49+
undefined
50+
);
51+
});
52+
});

0 commit comments

Comments
 (0)