diff --git a/packages/kiwi-core/src/CheckboxGroup/tests/CheckboxGroup.test.js b/packages/kiwi-core/src/CheckboxGroup/tests/CheckboxGroup.test.js new file mode 100644 index 00000000..da77ab10 --- /dev/null +++ b/packages/kiwi-core/src/CheckboxGroup/tests/CheckboxGroup.test.js @@ -0,0 +1,54 @@ +import { Box, Checkbox, CheckboxGroup } from '@/packages/kiwi-core/src' +import { render, defaultProviders } from '@/tests/test-utils' + +// mocks +import { useId } from '@/packages/kiwi-core/src/utils' +jest.mock('@/packages/kiwi-core/src/utils/generators.js') +jest.mock('breadstick/dist/components/Alert/styles.css', () => ({})) // jest tries to import styles and fails... + +const renderComponent = (props) => { + const base = { + components: { Box, Checkbox, CheckboxGroup }, + provide: () => defaultProviders(), + data: () => ({ selectedValues: ['two'] }), + template: ` + + + One + Two + Three + + `, + ...props + } + return render(base) +} + +it('should render correctly', () => { + useId.mockReturnValueOnce('1') + useId.mockReturnValueOnce('2') + useId.mockReturnValueOnce('3') + + const { asFragment } = renderComponent() + + expect(asFragment()).toMatchSnapshot() +}) + +it('should display children', () => { + const { getByText } = renderComponent() + expect(getByText('One')).toBeInTheDocument() + expect(getByText('Two')).toBeInTheDocument() + expect(getByText('Three')).toBeInTheDocument() +}) + +test('selectedValues prop works', () => { + const { getByTestId } = renderComponent() + + const one = getByTestId('one').querySelector('input') + const two = getByTestId('two').querySelector('input') + const three = getByTestId('three').querySelector('input') + + expect(one).not.toBeChecked() + expect(two).toBeChecked() + expect(three).not.toBeChecked() +}) diff --git a/packages/kiwi-core/src/CheckboxGroup/tests/__snapshots__/CheckboxGroup.test.js.snap b/packages/kiwi-core/src/CheckboxGroup/tests/__snapshots__/CheckboxGroup.test.js.snap new file mode 100644 index 00000000..89661248 --- /dev/null +++ b/packages/kiwi-core/src/CheckboxGroup/tests/__snapshots__/CheckboxGroup.test.js.snap @@ -0,0 +1,217 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + +
+
+
+ +
+
+ +
+
+ +
+
+
+
+`;