-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathindex.test.js
More file actions
46 lines (39 loc) · 1.79 KB
/
index.test.js
File metadata and controls
46 lines (39 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Copyright (c) 2024, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import React from 'react'
import {renderWithProviders} from '@salesforce/retail-react-app/app/utils/test-utils'
import {useForm} from 'react-hook-form'
import StandardLogin from '@salesforce/retail-react-app/app/components/standard-login'
import {screen} from '@testing-library/react'
const WrapperComponent = ({...props}) => {
const form = useForm()
return (
<form>
<StandardLogin form={form} {...props} />
</form>
)
}
describe('StandardLogin component', () => {
test('renders properly', () => {
renderWithProviders(<WrapperComponent />)
expect(screen.getByLabelText('Email')).toBeInTheDocument()
expect(screen.queryByLabelText('Password')).toBeInTheDocument()
expect(screen.getByRole('button', {name: 'Sign In'})).toBeInTheDocument()
})
test('renders properly when hideEmail is true', async () => {
renderWithProviders(<WrapperComponent hideEmail={true} />)
expect(screen.queryByLabelText('Email')).not.toBeInTheDocument()
expect(screen.getByLabelText('Password')).toBeInTheDocument()
expect(screen.getByRole('button', {name: 'Back to Sign In Options'})).toBeInTheDocument()
})
test('renders social login buttons', async () => {
renderWithProviders(<WrapperComponent isSocialEnabled={true} idps={['google', 'apple']} />)
expect(screen.getByText(/Or Login With/)).toBeInTheDocument()
expect(screen.getByRole('button', {name: /Google/})).toBeInTheDocument()
expect(screen.getByRole('button', {name: /Apple/})).toBeInTheDocument()
})
})