test: add checkbox test

This commit is contained in:
Sammy Teillet 2023-04-18 18:27:54 +02:00
parent 4d23390989
commit 3e09dab7fc
No known key found for this signature in database
GPG Key ID: 687E513E74D28696
3 changed files with 38 additions and 1 deletions

View File

@ -31,7 +31,12 @@ const StyledContainer = styled.span`
function Checkbox({ name, id }: OwnProps) {
return (
<StyledContainer>
<input type="checkbox" id={id} name={name}></input>
<input
type="checkbox"
data-testid="input-checkbox"
id={id}
name={name}
></input>
</StyledContainer>
);
}

View 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>
);
};

View 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',
);
});