chore: added a test that the selected types are rendered in the document

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2022-02-04 15:50:55 +01:00
parent 8afeb82cc3
commit 44f44f6408
@@ -127,4 +127,26 @@ describe('CategoryPicker', () => {
expect(mockSetSelectedTypes).toHaveBeenCalledWith(['foo', 'bar']);
});
it('should render the selectedTypes already in the document', async () => {
const mockAvailableTypes = ['foo', 'bar'];
const mockSelectedTypes = ['foo'];
(useEntityTypeFilter as jest.Mock).mockReturnValue({
availableTypes: mockAvailableTypes,
selectedTypes: mockSelectedTypes,
});
const { getByRole } = await renderInTestApp(
<TestApiProvider apis={[[alertApiRef, mockAlertApi]]}>
<CategoryPicker />
</TestApiProvider>,
);
const openButton = getByRole('button', { name: 'Open' });
await fireEvent(openButton, new MouseEvent('click', { bubbles: true }));
const fooCheckbox = getByRole('checkbox', { name: 'Foo' });
expect(fooCheckbox).toBeChecked();
});
});