-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46c0842
commit d23a05c
Showing
20 changed files
with
368 additions
and
58 deletions.
There are no files selected for viewing
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
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
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
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
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
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
35 changes: 35 additions & 0 deletions
35
src/components/CopyAdForm/__tests__/CopyAdFormFooter.spec.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,35 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import CopyAdFormFooter from '../CopyAdFormFooter'; | ||
|
||
const mockProps = { | ||
isValid: true, | ||
onClickCancel: jest.fn(), | ||
onSubmit: jest.fn(), | ||
}; | ||
|
||
jest.mock('@deriv-com/ui', () => ({ | ||
...jest.requireActual('@deriv-com/ui'), | ||
useDevice: () => ({ isMobile: false }), | ||
})); | ||
|
||
describe('CopyAdFormFooter', () => { | ||
it('should render the footer', () => { | ||
render(<CopyAdFormFooter {...mockProps} />); | ||
expect(screen.getByRole('button', { name: 'Cancel' })).toBeInTheDocument(); | ||
expect(screen.getByRole('button', { name: 'Create ad' })).toBeInTheDocument(); | ||
}); | ||
it('should handle the onClickCancel event', () => { | ||
render(<CopyAdFormFooter {...mockProps} />); | ||
screen.getByRole('button', { name: 'Cancel' }).click(); | ||
expect(mockProps.onClickCancel).toHaveBeenCalledTimes(1); | ||
}); | ||
it('should handle the onSubmit event', () => { | ||
render(<CopyAdFormFooter {...mockProps} />); | ||
screen.getByRole('button', { name: 'Create ad' }).click(); | ||
expect(mockProps.onSubmit).toHaveBeenCalledTimes(1); | ||
}); | ||
it('should disable the submit button when isValid is false', () => { | ||
render(<CopyAdFormFooter {...mockProps} isValid={false} />); | ||
expect(screen.getByRole('button', { name: 'Create ad' })).toBeDisabled(); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
src/components/CopyAdForm/__tests__/CopyAdFormHeader.spec.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,9 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import CopyAdFormHeader from '../CopyAdFormHeader'; | ||
|
||
describe('CopyAdFormHeader', () => { | ||
it('should render the header', () => { | ||
render(<CopyAdFormHeader />); | ||
expect(screen.getByText('Create a similar ad')).toBeInTheDocument(); | ||
}); | ||
}); |
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
Oops, something went wrong.