-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* disable filter options when live tailing mode is enabled * prevent seek direction change when stop loading is pressed on live mode * disable submit button while tailing * write tests for MultiSelect.styled component to achieve 100% coverage
- Loading branch information
1 parent
247fd23
commit 521ba0c
Showing
4 changed files
with
88 additions
and
8 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
61 changes: 61 additions & 0 deletions
61
kafka-ui-react-app/src/components/common/MultiSelect/__test__/MultiSelect.styled.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,61 @@ | ||
import React from 'react'; | ||
import { render } from 'lib/testHelpers'; | ||
import MultiSelect from 'components/common/MultiSelect/MultiSelect.styled'; | ||
import { ISelectProps } from 'react-multi-select-component/dist/lib/interfaces'; | ||
|
||
const Option1 = { value: 1, label: 'option 1' }; | ||
const Option2 = { value: 2, label: 'option 2' }; | ||
|
||
interface IMultiSelectProps extends ISelectProps { | ||
minWidth?: string; | ||
} | ||
|
||
const DefaultProps: IMultiSelectProps = { | ||
options: [Option1, Option2], | ||
labelledBy: 'multi-select', | ||
value: [Option1, Option2], | ||
}; | ||
|
||
describe('MultiSelect.Styled', () => { | ||
const setUpComponent = (props: IMultiSelectProps = DefaultProps) => { | ||
const { container } = render(<MultiSelect {...props} />); | ||
const multiSelect = container.firstChild; | ||
const dropdownContainer = multiSelect?.firstChild?.firstChild; | ||
|
||
return { container, multiSelect, dropdownContainer }; | ||
}; | ||
|
||
it('should have 200px minWidth by default', () => { | ||
const { container } = setUpComponent(); | ||
const multiSelect = container.firstChild; | ||
|
||
expect(multiSelect).toHaveStyle('min-width: 200px'); | ||
}); | ||
|
||
it('should have the provided minWidth in styles', () => { | ||
const minWidth = '400px'; | ||
const { container } = setUpComponent({ ...DefaultProps, minWidth }); | ||
const multiSelect = container.firstChild; | ||
|
||
expect(multiSelect).toHaveStyle(`min-width: ${minWidth}`); | ||
}); | ||
|
||
describe('when not disabled', () => { | ||
it('should have cursor pointer', () => { | ||
const { dropdownContainer } = setUpComponent(); | ||
|
||
expect(dropdownContainer).toHaveStyle(`cursor: pointer`); | ||
}); | ||
}); | ||
|
||
describe('when disabled', () => { | ||
it('should have cursor not-allowed', () => { | ||
const { dropdownContainer } = setUpComponent({ | ||
...DefaultProps, | ||
disabled: true, | ||
}); | ||
|
||
expect(dropdownContainer).toHaveStyle(`cursor: not-allowed`); | ||
}); | ||
}); | ||
}); |
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