-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Select): added errorMessage, errorPlacement and validationType p…
…rops (#1291)
- Loading branch information
Showing
9 changed files
with
184 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
|
||
import {render, screen} from '@testing-library/react'; | ||
|
||
import {CONTROL_ERROR_MESSAGE_QA} from '../../controls/utils'; | ||
import {Select} from '../Select'; | ||
|
||
describe('Select error', () => { | ||
test('render error message with error prop (if it is not an empty string)', () => { | ||
render(<Select error="Some Error" />); | ||
|
||
expect(screen.getByText('Some Error')).toBeVisible(); | ||
}); | ||
|
||
test('render error message with errorMessage prop (if it is not an empty string)', () => { | ||
render(<Select errorMessage="Some Error with errorMessage prop" />); | ||
|
||
expect(screen.queryByText('Some Error with errorMessage prop')).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('render error message with errorMessage prop and invalid state (if it is not an empty string)', () => { | ||
render( | ||
<Select errorMessage="Some Error with errorMessage prop" validationState="invalid" />, | ||
); | ||
|
||
expect(screen.getByText('Some Error with errorMessage prop')).toBeVisible(); | ||
}); | ||
|
||
test('render error icon if tooltip option is selected for errorPlacement prop', () => { | ||
render( | ||
<Select errorMessage="Some Error" validationState="invalid" errorPlacement="inside" />, | ||
); | ||
|
||
expect(screen.getByLabelText('Show popup with error info')).toBeInTheDocument(); | ||
}); | ||
|
||
test('do not show error message without error/errorMessage prop', () => { | ||
render(<Select />); | ||
|
||
expect(screen.queryByTestId(CONTROL_ERROR_MESSAGE_QA)).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('do not show error message if error prop value is an empty string', () => { | ||
render(<Select error={''} />); | ||
|
||
expect(screen.queryByTestId(CONTROL_ERROR_MESSAGE_QA)).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('do not show error message if errorMessage prop value is an empty string', () => { | ||
render(<Select errorMessage={''} />); | ||
|
||
expect(screen.queryByTestId(CONTROL_ERROR_MESSAGE_QA)).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('do not show error icon if error prop is an empty string', () => { | ||
render(<Select error={''} errorPlacement="inside" />); | ||
|
||
expect(screen.queryByLabelText('Show popup with error info')).not.toBeInTheDocument(); | ||
}); | ||
|
||
test('do not show error icon if errorMessage prop is an empty string', () => { | ||
render(<Select errorMessage={''} errorPlacement="inside" />); | ||
|
||
expect(screen.queryByLabelText('Show popup with error info')).not.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
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,3 +1,4 @@ | ||
{ | ||
"label_clear": "Clear" | ||
"label_clear": "Clear", | ||
"label_show-error-info": "Show popup with error info" | ||
} |
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,3 +1,4 @@ | ||
{ | ||
"label_clear": "Очистить" | ||
"label_clear": "Очистить", | ||
"label_show-error-info": "Показать попап с информацей об ошибке" | ||
} |
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