Skip to content

Commit

Permalink
test: Update for rejected optimizely.onReady
Browse files Browse the repository at this point in the history
  • Loading branch information
mikechu-optimizely committed Dec 28, 2023
1 parent e8e75cd commit 96ccc41
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,16 @@ export class OptimizelyProvider extends React.Component<OptimizelyProviderProps,
attributes: {},
};
} else {
await optimizely.onReady();

finalUser = {
id: optimizely.getVuid() || null,
attributes: {},
};
try {
await optimizely.onReady();

finalUser = {
id: optimizely.getVuid() || null,
attributes: {},
};
} catch {
logger.error('Unable to set user. The Optimizely SDK client is not ready.');
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/withOptimizely.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('withOptimizely', () => {
optimizelyClient = ({
setUser: jest.fn(),
getVuid: jest.fn(),
onReady: jest.fn(),
} as unknown) as ReactSDKClient;
});

Expand Down

0 comments on commit 96ccc41

Please sign in to comment.