Skip to content

Commit

Permalink
EDSC-3890-1: Clean up test
Browse files Browse the repository at this point in the history
  • Loading branch information
eudoroolivares2016 committed Dec 1, 2023
1 parent 1a88ebb commit 3f05f7b
Showing 1 changed file with 10 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Router } from 'react-router'
import { Provider } from 'react-redux'
import { createMemoryHistory } from 'history'
import ChunkedOrderModal from '../ChunkedOrderModal'
import PortalLinkContainer from '../../../containers/PortalLinkContainer/PortalLinkContainer'

import configureStore from '../../../store/configureStore'

Expand All @@ -19,33 +20,14 @@ beforeEach(() => {
jest.clearAllMocks()
})

jest.mock('../../../containers/PortalLinkContainer/PortalLinkContainer', () => jest.fn(({ children }) => {
console.log('🚀 ~ file: ChunkedOrderModal.test.js:34 ~ jest.mock ~ children:', children)

return (
<mock-comp
data-testid="PortalLinkContainer"
onClick={mockOnToggleChunkedOrderModal}
>
{children}
</mock-comp>
)
}))

import PortalLinkContainer from '../../../containers/PortalLinkContainer/PortalLinkContainer'

// Jest.mock('node-fetch')

// jest.mock('../../../containers/PortalLinkContainer/PortalLinkContainer', () => ({
// ...jest.requireActual('../../../containers/PortalLinkContainer/PortalLinkContainer'),
// Link: 'Link',
// Route: ({ children, path }) => children({ match: path === '/search' })
// }))

// jest.mock('../../../containers/PortalLinkContainer/PortalLinkContainer', () => ({
// updatePath,
// onClick
// }) => `This is PortalLinkContainer bool:${updatePath} this is onClick: ${onClick}`)
// In order to pass out of scope variables into `jest` they must be prefixed with `mock`
jest.mock('../../../containers/PortalLinkContainer/PortalLinkContainer', () => jest.fn(({ children }) => (
<mock-PortalLinkContainer
onClick={mockOnToggleChunkedOrderModal}
>
{children}
</mock-PortalLinkContainer>
)))

const store = configureStore()

Expand Down Expand Up @@ -144,11 +126,8 @@ describe('ChunkedOrderModal component', () => {
test('\'Refine your search\' button should trigger onToggleChunkedOrderModal', async () => {
const user = userEvent.setup()
const { onToggleChunkedOrderModal } = setup()
// Await user.click(screen.getByRole('button', { name: 'Refine your search' }))
await user.click(screen.getByTestId('PortalLinkContainer'))
await user.click(screen.getByText('Refine your search'))
expect(onToggleChunkedOrderModal).toHaveBeenCalledTimes(1)
// expect(PortalLinkContainer).toHaveBeenCalledWith(onToggleChunkedOrderModal)
// Expect(onToggleChunkedOrderModal).toHaveBeenCalledWith(false)
})

test('\'Change access methods\' button should trigger onToggleChunkedOrderModal', async () => {
Expand Down

0 comments on commit 3f05f7b

Please sign in to comment.