-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cover all dump component in the tests
- Loading branch information
1 parent
f3883d2
commit 1dfb643
Showing
15 changed files
with
220 additions
and
22 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { render } from '@testing-library/react'; | ||
import { Divider } from './divider'; | ||
|
||
describe('Divider', () => { | ||
it('should render', () => { | ||
expect(true).toBeTruthy(); | ||
const { baseElement } = render(<Divider />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
|
||
describe('when the button is clicked', () => {}); | ||
}); |
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 |
---|---|---|
@@ -1,7 +1,20 @@ | ||
import { configure, render } from '@testing-library/react'; | ||
import { Icon } from './icon'; | ||
import { IconProps } from './icon.interface'; | ||
|
||
describe('Icon', () => { | ||
it('should render', () => { | ||
expect(true).toBeTruthy(); | ||
let iconProps: IconProps; | ||
|
||
beforeEach(() => { | ||
configure({ throwSuggestions: true }); | ||
|
||
iconProps = { | ||
icon: 'icon', | ||
}; | ||
}); | ||
|
||
describe('when the button is clicked', () => {}); | ||
it('should render', () => { | ||
const { baseElement } = render(<Icon {...iconProps} />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,7 +1,63 @@ | ||
import { configure, render } from '@testing-library/react'; | ||
import { Input } from './input'; | ||
import { InputProps } from './input.interface'; | ||
import '@testing-library/jest-dom'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
describe('Input', () => { | ||
let inputProps: InputProps; | ||
|
||
beforeEach(() => { | ||
configure({ throwSuggestions: true }); | ||
|
||
inputProps = { | ||
value: 'hello world', | ||
placeholder: 'placeholder test', | ||
handleInputChange: jest.fn(), | ||
}; | ||
}); | ||
|
||
it('should render', () => { | ||
expect(true).toBeTruthy(); | ||
const { baseElement } = render(<Input {...inputProps} />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
|
||
describe('when the button is clicked', () => {}); | ||
describe('when the input is rendered', () => { | ||
it('should have the correct value', () => { | ||
const { getByRole } = render(<Input {...inputProps} />); | ||
const input = getByRole('textbox'); | ||
expect(input).toHaveValue('hello world'); | ||
}); | ||
|
||
it('should have the correct placeholder', () => { | ||
const { getByRole } = render(<Input {...inputProps} />); | ||
const input = getByRole('textbox'); | ||
expect(input).toHaveAttribute('placeholder', 'placeholder test'); | ||
}); | ||
}); | ||
|
||
describe('when the text to the input is entered', () => { | ||
it('should call the handleInputChange function when the input changes', async () => { | ||
const { getByRole } = render(<Input {...inputProps} />); | ||
const input = getByRole('textbox'); | ||
await userEvent.type(input, 'qwerty', { delay: 1 }); | ||
expect(inputProps.handleInputChange).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should call the handleInputChange function 3 times for 3 characters', async () => { | ||
const { getByRole } = render(<Input {...inputProps} />); | ||
const input = getByRole('textbox'); | ||
await userEvent.type(input, 'abc', { delay: 1 }); | ||
expect(inputProps.handleInputChange).toHaveBeenCalledTimes(3); | ||
}); | ||
|
||
it('should call the handleInputChange function with correct phrase', async () => { | ||
const { getByRole } = render(<Input {...inputProps} />); | ||
const input = getByRole('textbox'); | ||
await userEvent.type(input, '123', { delay: 1 }); | ||
expect(inputProps.handleInputChange).toHaveBeenCalledWith( | ||
'hello world123' | ||
); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,7 +1,29 @@ | ||
import { configure, render } from '@testing-library/react'; | ||
import { Text } from './text'; | ||
import { TextProps } from './text.interface'; | ||
import '@testing-library/jest-dom'; | ||
|
||
describe('Text', () => { | ||
let textProps: TextProps; | ||
|
||
beforeEach(() => { | ||
configure({ throwSuggestions: true }); | ||
|
||
textProps = { | ||
text: 'hello world', | ||
}; | ||
}); | ||
|
||
it('should render', () => { | ||
expect(true).toBeTruthy(); | ||
const { baseElement } = render(<Text {...textProps} />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
|
||
describe('when the button is clicked', () => {}); | ||
describe('when the text is rendered', () => { | ||
it('should have the correct value', () => { | ||
const { getByText } = render(<Text {...textProps} />); | ||
const text = getByText('hello world'); | ||
expect(text).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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,66 @@ | ||
import { TextAreaProps } from './text-area.interface'; | ||
import '@testing-library/jest-dom'; | ||
import { configure, render } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { TextArea } from './text-area'; | ||
|
||
describe('TextArea', () => { | ||
let textAreaProps: TextAreaProps; | ||
|
||
beforeEach(() => { | ||
configure({ throwSuggestions: true }); | ||
|
||
textAreaProps = { | ||
value: 'hello textarea', | ||
placeholder: 'placeholder test for textarea', | ||
handleTextAreaChange: jest.fn(), | ||
}; | ||
}); | ||
|
||
it('should render', () => { | ||
expect(true).toBeTruthy(); | ||
const { baseElement } = render(<TextArea {...textAreaProps} />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
|
||
describe('when the button is clicked', () => {}); | ||
describe('when the text area is rendered', () => { | ||
it('should have the correct value', () => { | ||
const { getByRole } = render(<TextArea {...textAreaProps} />); | ||
const textarea = getByRole('textbox'); | ||
expect(textarea).toHaveValue('hello textarea'); | ||
}); | ||
|
||
it('should have the correct placeholder', () => { | ||
const { getByRole } = render(<TextArea {...textAreaProps} />); | ||
const textarea = getByRole('textbox'); | ||
expect(textarea).toHaveAttribute( | ||
'placeholder', | ||
'placeholder test for textarea' | ||
); | ||
}); | ||
}); | ||
|
||
describe('when the text to the text area is entered', () => { | ||
it('should call the handleTextAreaChange function when the input changes', async () => { | ||
const { getByRole } = render(<TextArea {...textAreaProps} />); | ||
const textarea = getByRole('textbox'); | ||
await userEvent.type(textarea, 'qwerty', { delay: 1 }); | ||
expect(textAreaProps.handleTextAreaChange).toHaveBeenCalled(); | ||
}); | ||
|
||
it('should call the handleTextAreaChange function 3 times for 3 characters', async () => { | ||
const { getByRole } = render(<TextArea {...textAreaProps} />); | ||
const textarea = getByRole('textbox'); | ||
await userEvent.type(textarea, 'abc', { delay: 1 }); | ||
expect(textAreaProps.handleTextAreaChange).toHaveBeenCalledTimes(3); | ||
}); | ||
|
||
it('should call the handleTextAreaChange function with correct phrase', async () => { | ||
const { getByRole } = render(<TextArea {...textAreaProps} />); | ||
const textarea = getByRole('textbox'); | ||
await userEvent.type(textarea, '1', { delay: 1 }); | ||
expect(textAreaProps.handleTextAreaChange).toHaveBeenCalledWith( | ||
'hello textarea1' | ||
); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,7 +1,29 @@ | ||
import { configure, render } from '@testing-library/react'; | ||
import { Title } from './title'; | ||
import { TitleProps } from './title.interface'; | ||
import '@testing-library/jest-dom'; | ||
|
||
describe('Title', () => { | ||
let titleProps: TitleProps; | ||
|
||
beforeEach(() => { | ||
configure({ throwSuggestions: true }); | ||
|
||
titleProps = { | ||
title: 'hello title world', | ||
}; | ||
}); | ||
|
||
it('should render', () => { | ||
expect(true).toBeTruthy(); | ||
const { baseElement } = render(<Title {...titleProps} />); | ||
expect(baseElement).toBeTruthy(); | ||
}); | ||
|
||
describe('when the button is clicked', () => {}); | ||
describe('when the title is rendered', () => { | ||
it('should have the correct value', () => { | ||
const { getByRole } = render(<Title {...titleProps} />); | ||
const title = getByRole('heading', { name: /hello title world/i }); | ||
expect(title).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