Skip to content

Commit 74f2221

Browse files
committed
RI-6242 added tests
1 parent 9ec9d92 commit 74f2221

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

redisinsight/ui/src/components/oauth/oauth-user-profile/OAuthUserProfile.spec.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ const mockedProps = mock<Props>()
2121
jest.mock('uiSrc/slices/oauth/cloud', () => ({
2222
...jest.requireActual('uiSrc/slices/oauth/cloud'),
2323
oauthCloudUserSelector: jest.fn().mockReturnValue({
24-
data: null
24+
loading: false,
25+
data: null,
26+
error: '',
2527
}),
2628
}))
2729

@@ -50,7 +52,20 @@ describe('OAuthUserProfile', () => {
5052
expect(render(<OAuthUserProfile {...mockedProps} />)).toBeTruthy()
5153
})
5254

55+
it('should render loading spinner initially', () => {
56+
render(<OAuthUserProfile {...mockedProps} />)
57+
58+
expect(screen.getByTestId('oath-user-profile-spinner')).toBeInTheDocument()
59+
expect(screen.queryByTestId('cloud-sign-in-btn')).not.toBeInTheDocument()
60+
expect(screen.queryByTestId('user-profile-btn')).not.toBeInTheDocument()
61+
})
62+
5363
it('should render sign in button if no profile', () => {
64+
(oauthCloudUserSelector as jest.Mock).mockReturnValue({
65+
loading: false,
66+
data: null,
67+
error: 'Some error',
68+
})
5469
render(<OAuthUserProfile {...mockedProps} />)
5570

5671
expect(screen.getByTestId('cloud-sign-in-btn')).toBeInTheDocument()

redisinsight/ui/src/components/oauth/oauth-user-profile/OAuthUserProfile.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ const OAuthUserProfile = (props: Props) => {
4949
if (profileLoading) {
5050
return (
5151
<div className={styles.loadingContainer}>
52-
<EuiLoadingSpinner className={cx('infiniteMessage__icon', styles.loading)} size="l" />
52+
<EuiLoadingSpinner
53+
className={cx('infiniteMessage__icon', styles.loading)}
54+
size="l"
55+
data-testid="oath-user-profile-spinner"
56+
/>
5357
</div>
5458
)
5559
}

0 commit comments

Comments
 (0)