-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leshe4ka
committed
May 17, 2024
1 parent
0b6286d
commit dd93106
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
frontend/src/components/Nav/Menu/MenuColorPicker/__tests__/MenuColorPicker.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { fireEvent, screen } from '@testing-library/react'; | ||
import MenuColorPicker, { | ||
MenuColorPickerProps, | ||
} from 'components/Nav/Menu/MenuColorPicker/MenuColorPicker'; | ||
import React from 'react'; | ||
import { render } from 'lib/testHelpers'; | ||
import { ClusterColorKey } from 'theme/theme'; | ||
|
||
describe('MenuColorPicker component', () => { | ||
const setupWrapper = (props?: Partial<MenuColorPickerProps>) => ( | ||
<MenuColorPicker setColorKey={jest.fn()} {...props} /> | ||
); | ||
|
||
it('renders all color circles', () => { | ||
render(setupWrapper()); | ||
|
||
const colorKeys: ClusterColorKey[] = [ | ||
'transparent', | ||
'gray', | ||
'red', | ||
'orange', | ||
'lettuce', | ||
'green', | ||
'turquoise', | ||
'blue', | ||
'violet', | ||
'pink', | ||
]; | ||
|
||
colorKeys.forEach((key) => { | ||
expect(screen.getByTestId(`color-circle-${key}`)).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('calls setColorKey with the correct color key when a color circle is clicked', () => { | ||
const setColorKeyMock = jest.fn(); | ||
render(setupWrapper({ setColorKey: setColorKeyMock })); | ||
|
||
const colorCircle = screen.getByTestId('color-circle-red'); | ||
fireEvent.click(colorCircle); | ||
|
||
expect(setColorKeyMock).toHaveBeenCalledWith('red'); | ||
}); | ||
|
||
it('renders the Dropdown component', () => { | ||
render(setupWrapper()); | ||
expect(screen.getByRole('button')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters