From 44f44f6408b2f4d7d565846038800c7ed194e887 Mon Sep 17 00:00:00 2001 From: blam Date: Fri, 4 Feb 2022 15:50:55 +0100 Subject: [PATCH] chore: added a test that the selected types are rendered in the document Signed-off-by: blam --- .../TemplateListPage/CategoryPicker.test.tsx | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/plugins/scaffolder/src/next/TemplateListPage/CategoryPicker.test.tsx b/plugins/scaffolder/src/next/TemplateListPage/CategoryPicker.test.tsx index a04d382445..f02ca51354 100644 --- a/plugins/scaffolder/src/next/TemplateListPage/CategoryPicker.test.tsx +++ b/plugins/scaffolder/src/next/TemplateListPage/CategoryPicker.test.tsx @@ -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( + + + , + ); + + const openButton = getByRole('button', { name: 'Open' }); + await fireEvent(openButton, new MouseEvent('click', { bubbles: true })); + + const fooCheckbox = getByRole('checkbox', { name: 'Foo' }); + expect(fooCheckbox).toBeChecked(); + }); });