Skip to content

Commit 668dc84

Browse files
committed
test(expo): configure the fake native module through configureWithOptions
1 parent 378697d commit 668dc84

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎packages/expo/src/provider/__tests__/nativeClientSyncBehavior/currentEngineAdapter.tsx‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ function serializeClient(native: FakeNativeClerk): string {
2424
function createCurrentNativeModule(native: FakeNativeClerk, calls: string[]): ClerkExpoNativeModule {
2525
const listeners = new Set<(snapshot: NativeClientSnapshot) => void>();
2626

27+
const configure = async (bearerToken: string | null) => {
28+
await native.waitForStartup();
29+
if (bearerToken && (bearerToken !== native.token || !native.client)) {
30+
await native.adoptToken(bearerToken);
31+
} else {
32+
await native.refreshClient();
33+
}
34+
native.isConfigured = true;
35+
};
36+
2737
native.onChange((change, origin) => {
2838
const snapshot: NativeClientSnapshot = {
2939
changed: { client: change.client, deviceToken: change.deviceToken },
@@ -45,15 +55,13 @@ function createCurrentNativeModule(native: FakeNativeClerk, calls: string[]): Cl
4555
listeners.add(typedListener);
4656
return { remove: () => listeners.delete(typedListener) };
4757
},
48-
configure: async (_publishableKey: string, bearerToken: string | null) => {
58+
configure: (_publishableKey: string, bearerToken: string | null) => {
4959
calls.push('configure');
50-
await native.waitForStartup();
51-
if (bearerToken && (bearerToken !== native.token || !native.client)) {
52-
await native.adoptToken(bearerToken);
53-
} else {
54-
await native.refreshClient();
55-
}
56-
native.isConfigured = true;
60+
return configure(bearerToken);
61+
},
62+
configureWithOptions: (_publishableKey: string, options: { bearerToken: string | null }) => {
63+
calls.push('configureWithOptions');
64+
return configure(options.bearerToken);
5765
},
5866
getClientToken: () => {
5967
calls.push('getClientToken');

0 commit comments

Comments
 (0)