-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathask-assistant-banner.test.jsx
More file actions
49 lines (42 loc) · 1.75 KB
/
ask-assistant-banner.test.jsx
File metadata and controls
49 lines (42 loc) · 1.75 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
47
48
49
/*
* Copyright (c) 2025, 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 {screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import {renderWithProviders} from '@salesforce/retail-react-app/app/utils/test-utils'
import AskAssistantBanner from '@salesforce/retail-react-app/app/components/search/partials/ask-assistant-banner'
const baseStyles = {
askAssistantBanner: {},
askAssistantBannerContent: {},
askAssistantBannerTitleRow: {},
askAssistantBannerIcon: {},
askAssistantBannerTitle: {},
askAssistantBannerDescription: {},
askAssistantBannerArrow: {}
}
test('renders Ask Shopping Agent banner with title and description', () => {
renderWithProviders(<AskAssistantBanner onClick={jest.fn()} styles={baseStyles} />)
expect(
screen.getByRole('button', {
name: /Ask Shopping Agent.*discover, compare and shop smarter/i
})
).toBeInTheDocument()
expect(screen.getByText((content) => content === 'Ask Shopping Agent')).toBeInTheDocument()
expect(
screen.getByText(/Discover, compare, and shop smarter with your personal Shopping Agent/i)
).toBeInTheDocument()
})
test('calls onClick when banner is clicked', async () => {
const user = userEvent.setup()
const onClick = jest.fn()
renderWithProviders(<AskAssistantBanner onClick={onClick} styles={baseStyles} />)
const button = screen.getByRole('button', {
name: /Ask Shopping Agent.*discover, compare and shop smarter/i
})
await user.click(button)
expect(onClick).toHaveBeenCalledTimes(1)
})