mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
fix: show popover on empty state (#5611)
This commit is contained in:
parent
43c563af57
commit
850b78a699
@ -5,7 +5,7 @@ import { FilterDateItem, IFilterDateItemProps } from './FilterDateItem';
|
||||
|
||||
const getDate = (option: string) => screen.getByText(option);
|
||||
|
||||
const setup = (initialState: FilterItemParams) => {
|
||||
const setup = (initialState: FilterItemParams | null) => {
|
||||
const recordedChanges: FilterItemParams[] = [];
|
||||
const mockProps: IFilterDateItemProps = {
|
||||
label: 'Test Label',
|
||||
@ -51,6 +51,14 @@ describe('FilterDateItem Component', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('renders initial popover when no existing value', async () => {
|
||||
const mockState = null;
|
||||
|
||||
const recordedChanges = setup(mockState);
|
||||
|
||||
await screen.findByText('21');
|
||||
});
|
||||
|
||||
it('switches operator', async () => {
|
||||
const mockState = {
|
||||
operator: 'IS_ON_OR_AFTER',
|
||||
|
@ -33,7 +33,9 @@ export const FilterDateItem: FC<IFilterDateItemProps> = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
open();
|
||||
if (!state) {
|
||||
open();
|
||||
}
|
||||
}, []);
|
||||
|
||||
const onClose = () => {
|
||||
|
@ -5,7 +5,7 @@ import { FilterItem, FilterItemParams, IFilterItemProps } from './FilterItem';
|
||||
const getOption = (option: string) =>
|
||||
screen.getByText(option).closest('li')!.querySelector('input')!;
|
||||
|
||||
const setup = (initialState: FilterItemParams) => {
|
||||
const setup = (initialState: FilterItemParams | null) => {
|
||||
const recordedChanges: FilterItemParams[] = [];
|
||||
const mockProps: IFilterItemProps = {
|
||||
label: 'Test Label',
|
||||
@ -67,6 +67,14 @@ describe('FilterItem Component', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('renders initial popover when no existing value', async () => {
|
||||
const mockState = null;
|
||||
|
||||
const recordedChanges = setup(mockState);
|
||||
|
||||
await screen.findByPlaceholderText('Search');
|
||||
});
|
||||
|
||||
it('renders explicit and extra options', async () => {
|
||||
const mockState = {
|
||||
operator: 'IS_ANY_OF',
|
||||
|
@ -46,7 +46,9 @@ export const FilterItem: FC<IFilterItemProps> = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
open();
|
||||
if (!state) {
|
||||
open();
|
||||
}
|
||||
}, []);
|
||||
|
||||
const onClose = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user