Skip to content

Commit 567ed42

Browse files
update test
1 parent 306b522 commit 567ed42

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

src/__tests__/useSplitClient.test.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,25 @@ test('useSplitClient must update on SDK events', () => {
3030
<SplitContext.Consumer>
3131
{() => countSplitContext++}
3232
</SplitContext.Consumer>
33-
<SplitClient splitKey={sdkBrowser.core.key}>
33+
<SplitClient splitKey={sdkBrowser.core.key} trafficType={sdkBrowser.core.trafficType}
34+
/* Disabling update props is ineffective because the wrapping SplitFactory has them enabled: */
35+
updateOnSdkReady={false} updateOnSdkReadyFromCache={false}
36+
>
3437
{() => { countSplitClient++; return null }}
3538
</SplitClient>
36-
<SplitClient splitKey={'user_2'}>
37-
{() => { countSplitClientUser2++; return null }}
38-
</SplitClient>
3939
{React.createElement(() => {
40-
const { client } = useSplitClient(sdkBrowser.core.key, sdkBrowser.core.trafficType, { att1: 'att1' });
40+
// Equivalent to
41+
// - Using config key and traffic type: `const { client } = useSplitClient(sdkBrowser.core.key, sdkBrowser.core.trafficType, { att1: 'att1' });`
42+
// - Disabling update props, since the wrapping SplitFactory has them enabled: `const { client } = useSplitClient(undefined, undefined, { att1: 'att1' }, { updateOnSdkReady: false, updateOnSdkReadyFromCache: false });`
43+
const { client } = useSplitClient(undefined, undefined, { att1: 'att1' });
4144
expect(client).toBe(mainClient); // Assert that the main client was retrieved.
4245
expect(client!.getAttributes()).toEqual({ att1: 'att1' }); // Assert that the client was retrieved with the provided attributes.
4346
countUseSplitClient++;
4447
return null;
4548
})}
49+
<SplitClient splitKey={'user_2'}>
50+
{() => { countSplitClientUser2++; return null }}
51+
</SplitClient>
4652
{React.createElement(() => {
4753
const { client } = useSplitClient('user_2');
4854
expect(client).toBe(user2Client);

0 commit comments

Comments
 (0)