test: add checkbox test
This commit is contained in:
@ -31,7 +31,12 @@ const StyledContainer = styled.span`
|
|||||||
function Checkbox({ name, id }: OwnProps) {
|
function Checkbox({ name, id }: OwnProps) {
|
||||||
return (
|
return (
|
||||||
<StyledContainer>
|
<StyledContainer>
|
||||||
<input type="checkbox" id={id} name={name}></input>
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
data-testid="input-checkbox"
|
||||||
|
id={id}
|
||||||
|
name={name}
|
||||||
|
></input>
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
20
front/src/components/form/__stories__/Checkbox.stories.tsx
Normal file
20
front/src/components/form/__stories__/Checkbox.stories.tsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { MemoryRouter } from 'react-router-dom';
|
||||||
|
|
||||||
|
import Checkbox from '../Checkbox';
|
||||||
|
import { ThemeProvider } from '@emotion/react';
|
||||||
|
import { lightTheme } from '../../../layout/styles/themes';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
title: 'Checkbox',
|
||||||
|
component: Checkbox,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const RegularCheckbox = () => {
|
||||||
|
return (
|
||||||
|
<ThemeProvider theme={lightTheme}>
|
||||||
|
<MemoryRouter initialEntries={['/companies']}>
|
||||||
|
<Checkbox name="selected-company-1" id="selected-company--1" />
|
||||||
|
</MemoryRouter>
|
||||||
|
</ThemeProvider>
|
||||||
|
);
|
||||||
|
};
|
||||||
12
front/src/components/form/__tests__/Checkbox.test.tsx
Normal file
12
front/src/components/form/__tests__/Checkbox.test.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { render } from '@testing-library/react';
|
||||||
|
|
||||||
|
import { RegularCheckbox } from '../__stories__/Checkbox.stories';
|
||||||
|
|
||||||
|
it('Checks the NavItem renders', () => {
|
||||||
|
const { getByTestId } = render(<RegularCheckbox />);
|
||||||
|
|
||||||
|
expect(getByTestId('input-checkbox')).toHaveAttribute(
|
||||||
|
'name',
|
||||||
|
'selected-company-1',
|
||||||
|
);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user