-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test cases added for Okta login bas screen
- Loading branch information
1 parent
a4c2ea0
commit 876968b
Showing
3 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
login-workflow/src/__tests__/screens/OktaLoginScreenBase.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// OktaLoginScreenBase.test.tsx | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react-native'; | ||
import { OktaLoginScreenBase } from 'src/screens'; | ||
import { View } from 'react-native'; | ||
|
||
describe('OktaLoginScreenBase', () => { | ||
test('renders Okta Login Screen Base component', () => { | ||
render(<OktaLoginScreenBase />); | ||
expect(<OktaLoginScreenBase />).toMatchSnapshot() | ||
}); | ||
|
||
test('renders self-register button if selfRegisterButtonLabel is provided', () => { | ||
const { getByTestId } = render(<OktaLoginScreenBase showSelfRegistration={true} selfRegisterButtonLabel="Register now!" />); | ||
const registerButton = getByTestId('blui-okta-login-self-register-label'); | ||
expect(registerButton).toBeTruthy(); | ||
expect(registerButton.props.children).toBe('Register now!'); | ||
}); | ||
|
||
test('renders contact support section if showContactSupport is true', () => { | ||
const { getByTestId } = render(<OktaLoginScreenBase showContactSupport={true} />); | ||
const contactSupportWrapper = getByTestId('blui-okta-login-contact-support-wrapper'); | ||
expect(contactSupportWrapper).toBeTruthy(); | ||
}); | ||
|
||
test('renders contact support label with correct text', () => { | ||
const { getByTestId } = render(<OktaLoginScreenBase showContactSupport={true} contactSupportLabel="Contact Support" />); | ||
const contactSupportLabel = getByTestId('blui-okta-login-contact-support-label'); | ||
expect(contactSupportLabel).toBeTruthy(); | ||
expect(contactSupportLabel.props.children).toBe('Contact Support'); | ||
}); | ||
|
||
test('calls handleContactSupport when contact support label is pressed', () => { | ||
const handleContactSupport = jest.fn(); | ||
const { getByTestId } = render(<OktaLoginScreenBase showContactSupport={true} onContactSupport={handleContactSupport} />); | ||
const contactSupportLabel = getByTestId('blui-okta-login-contact-support-label'); | ||
fireEvent.press(contactSupportLabel); | ||
expect(handleContactSupport).toHaveBeenCalled(); | ||
}); | ||
|
||
test('renders footer content', () => { | ||
const { getByTestId } = render(<OktaLoginScreenBase footer={<View>Footer Content</View>} />); | ||
const footerContent = getByTestId('blui-okta-login-footer'); | ||
expect(footerContent).toBeTruthy(); | ||
expect(footerContent.props.children).toMatchSnapshot('Footer Content'); | ||
}); | ||
|
||
test('renders cybersecurity badge if showCyberSecurityBadge is true', () => { | ||
const { getByTestId } = render(<OktaLoginScreenBase showCyberSecurityBadge={true} />); | ||
const cyberSecurityBadgeWrapper = getByTestId('blui-okta-login-cyber-security-badge-wrapper'); | ||
expect(cyberSecurityBadgeWrapper).toBeTruthy(); | ||
}); | ||
|
||
test('renders cybersecurity badge image', () => { | ||
const imgSource = require('../../assets/images/cybersecurity_certified.png'); | ||
const { queryByTestId } = render(<OktaLoginScreenBase showCyberSecurityBadge={true} />); | ||
const cyberSecurityBadgeImage = queryByTestId('blui-okta-login-cyber-security-badge-image'); | ||
expect(cyberSecurityBadgeImage).toBeTruthy(); | ||
expect(queryByTestId('blui-okta-login-cyber-security-badge-image')?.props.source).toBe(imgSource); | ||
}); | ||
}); |
11 changes: 11 additions & 0 deletions
11
login-workflow/src/__tests__/screens/__snapshots__/OktaLoginScreenBase.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`OktaLoginScreenBase renders Okta Login Screen Base component 1`] = `<OktaLoginScreenBase />`; | ||
|
||
exports[`OktaLoginScreenBase renders footer content: Footer Content 1`] = ` | ||
<View> | ||
Footer Content | ||
</View> | ||
`; | ||
|
||
exports[`OktaLoginScreenBase renders self-register button if selfRegisterButtonLabel is provided 1`] = `null`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters