Skip to content

Commit

Permalink
[FSSDK-10880] new tests addition
Browse files Browse the repository at this point in the history
  • Loading branch information
junaed-optimizely committed Nov 7, 2024
1 parent 6c4ea48 commit 382692e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Provider.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ describe('OptimizelyProvider', () => {
});
});

it('should succeed with the initial user available in client', () => {
render(<OptimizelyProvider optimizely={mockReactClient} />);

expect(mockReactClient.setUser).toHaveBeenCalledWith(user1);
});

it('should succeed with the initial user id and newly passed attributes', () => {
render(<OptimizelyProvider optimizely={mockReactClient} userAttributes={{ attr1: 'value2' }} />);

expect(mockReactClient.setUser).toHaveBeenCalledWith({
id: user1.id,
attributes: { attr1: 'value2' },
});
});

it('should not update when isServerSide is true', () => {
// Initial render
const { rerender } = render(<OptimizelyProvider optimizely={mockReactClient} isServerSide={true} user={user1} />);
Expand Down

0 comments on commit 382692e

Please sign in to comment.