mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-22 19:41:53 +03:00
test: add checkbox test
This commit is contained in:
parent
4d23390989
commit
3e09dab7fc
@ -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>
|
||||
);
|
||||
}
|
||||
|
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',
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue
Block a user