-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathindex.test.jsx
More file actions
43 lines (42 loc) · 1.67 KB
/
index.test.jsx
File metadata and controls
43 lines (42 loc) · 1.67 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
/*
* Copyright (c) 2024, Salesforce, 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 {screen} from '@testing-library/react'
import {renderWithProviders} from '../../utils/test-utils'
import SocialLogin from '../../components/social-login/index'
describe('SocialLogin', () => {
test('Load Apple', async () => {
renderWithProviders(<SocialLogin idps={['Apple']} />)
const button = screen.getByText('Apple')
expect(button).toBeDefined()
})
test('Load Apple and Google', async () => {
renderWithProviders(<SocialLogin idps={['Apple', 'Google']} />)
const button = screen.getByText('Apple')
expect(button).toBeDefined()
const button2 = screen.getByText('Google')
expect(button2).toBeDefined()
})
/* expect nothing to be rendered for an empty list */
test('Load none', async () => {
renderWithProviders(<SocialLogin />)
const button = screen.queryByText('Google')
expect(button).toBeNull()
const button2 = screen.queryByText('Apple')
expect(button2).toBeNull()
})
/* expect unknown IDPs to be skipped over */
test('Load Unknown', async () => {
// to keep terminal clean
const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
renderWithProviders(<SocialLogin idps={['Unknown']} />)
const button = screen.queryByText('Unknown')
expect(button).toBeNull()
expect(consoleSpy).toHaveBeenCalled()
consoleSpy.mockRestore()
})
})