diff --git a/src/components/common/Checkbox/index.tsx b/src/components/common/Checkbox/index.tsx index 10313fe..1443cd4 100644 --- a/src/components/common/Checkbox/index.tsx +++ b/src/components/common/Checkbox/index.tsx @@ -42,12 +42,13 @@ const Checkbox = React.forwardRef( }; return ( - + ` const Icon = styled.svg` fill: none; stroke: white; - strokewidth: 2px; + stroke-width: 2px; `; const HiddenCheckbox = styled.input` diff --git a/src/components/common/Dialog/DialogToggle.tsx b/src/components/common/Dialog/DialogToggle.tsx index 655fd81..d4af761 100644 --- a/src/components/common/Dialog/DialogToggle.tsx +++ b/src/components/common/Dialog/DialogToggle.tsx @@ -4,7 +4,7 @@ import Slot from '@/components/Slot'; import useContext from '@/hooks/useContext'; import { composeEventHandlers } from '@/libs/event'; -import { Button } from '.'; +import { Button } from '../'; import DialogContext from './DialogContext'; type ComponentPropsWithoutRef = React.ComponentPropsWithoutRef & { diff --git a/src/components/common/Input/input.test.tsx b/src/components/common/Input/input.test.tsx new file mode 100644 index 0000000..cae5739 --- /dev/null +++ b/src/components/common/Input/input.test.tsx @@ -0,0 +1,24 @@ +import '@testing-library/jest-dom'; +import React from 'react'; +import { expect, it } from 'vitest'; + +import { Input, InputGroup, Label } from '../..'; +import { fireEvent, render, screen } from '../../../libs/test'; + +describe('Input', () => { + it('Fill out the Input', async () => { + render( + + + + , + {}, + ); + const emailValue = 'bandmator@bandmate.com'; + const emailInput = screen.getByLabelText(/email/i); + + fireEvent.change(emailInput, { target: { value: emailValue } }); + + expect(emailInput).toHaveValue(emailValue); + }); +}); diff --git a/src/components/common/Switch/index.tsx b/src/components/common/Switch/index.tsx index b5bc95c..094a575 100644 --- a/src/components/common/Switch/index.tsx +++ b/src/components/common/Switch/index.tsx @@ -57,14 +57,15 @@ export const Switch = React.forwardRef( }; return ( - + diff --git a/src/components/common/Switch/switch.test.tsx b/src/components/common/Switch/switch.test.tsx new file mode 100644 index 0000000..e3dabfe --- /dev/null +++ b/src/components/common/Switch/switch.test.tsx @@ -0,0 +1,42 @@ +import '@testing-library/jest-dom'; +import React from 'react'; +import { expect, it } from 'vitest'; + +import { Switch } from '../..'; +import { fireEvent, render, screen } from '../../../libs/test'; + +describe('Switch', () => { + it('Should be change checked value when click the Switch', async () => { + render(, {}); + + const label = screen.getByLabelText(/SwitchLabel/i); + expect(label).toBeInTheDocument(); + + const checkbox = screen.getByRole('checkbox'); + expect(checkbox).toBeInTheDocument(); + + // un checked + expect(checkbox).not.toBeChecked(); + + fireEvent.click(label); + + // checked + expect(checkbox).toBeChecked(); + }); + + it('Should be no change when click the Disabled Switch', async () => { + render(, {}); + + const label = screen.getByLabelText(/SwitchLabel/i); + expect(label).toBeInTheDocument(); + + const checkbox = screen.getByRole('checkbox'); + expect(checkbox).toBeInTheDocument(); + + expect(checkbox).not.toBeChecked(); + + fireEvent.click(checkbox); + + expect(checkbox).toBeDisabled(); + }); +}); diff --git a/src/components/common/Textarea/textarea.test.tsx b/src/components/common/Textarea/textarea.test.tsx new file mode 100644 index 0000000..1eddf9b --- /dev/null +++ b/src/components/common/Textarea/textarea.test.tsx @@ -0,0 +1,25 @@ +import '@testing-library/jest-dom'; +import React from 'react'; +import { expect, it } from 'vitest'; + +import { InputDesc, InputGroup, Label, Textarea } from '../..'; +import { fireEvent, render, screen } from '../../../libs/test'; + +describe('Textarea', () => { + it('Fill out the Textarea', async () => { + render( + + +