-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: light UI redesign #30
base: master
Are you sure you want to change the base?
Changes from 1 commit
3046ba3
8fdb6da
9632ca8
e570df9
65cff3a
be425ad
9b4978f
5270296
00f510f
455854e
53f613d
3fea811
800f11a
f8ea525
c26c0fb
701d845
98ab742
b35c74f
e64a79e
5bf37fa
cc0c32c
af392bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { | |
RenderResult, | ||
waitFor, | ||
fireEvent, | ||
getAllByTestId, | ||
} from '@testing-library/react'; | ||
import { act } from 'react-dom/test-utils'; | ||
|
||
|
@@ -26,63 +27,17 @@ describe('Popup', () => { | |
utils = render(<Popup />); | ||
}); | ||
|
||
const { queryAllByLabelText } = utils; | ||
const { queryAllByLabelText, getByTestId, getAllByTestId } = utils; | ||
|
||
(chromeHelpers.getActiveColor as jest.Mock).mockResolvedValue(COLORS[0]); | ||
|
||
await waitFor(() => expect(chromeHelpers.getActiveColor).toHaveBeenCalled()); | ||
|
||
const colorButtons = queryAllByLabelText('save color'); | ||
const colorButtons = getAllByTestId('color button'); | ||
const whiteList = queryAllByLabelText('whitelist toggle'); | ||
const customForm = queryAllByLabelText('custom form'); | ||
|
||
expect(colorButtons[0]).toHaveClass('colorLinks--button active'); | ||
expect(whiteList.length).toEqual(1); | ||
expect(customForm.length).toEqual(0); | ||
}); | ||
|
||
it('should show custom input when no active color found', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Active color always exists, so I removed this test. |
||
let utils = {} as RenderResult; | ||
|
||
act(async () => { | ||
utils = render(<Popup />); | ||
}); | ||
|
||
const { getByLabelText, queryAllByLabelText, container } = utils; | ||
|
||
(chromeHelpers.getActiveColor as jest.Mock).mockResolvedValue(''); | ||
|
||
await waitFor(() => expect(chromeHelpers.getActiveColor).toHaveBeenCalled()); | ||
|
||
const customColor = getByLabelText('custom color'); | ||
const customForm = queryAllByLabelText('custom form'); | ||
|
||
expect(customColor).toHaveClass('colorLinks--button active'); | ||
await waitFor(() => expect(customForm.length).toEqual(1), { container }); | ||
}); | ||
|
||
it('should show a custom input when the custom color button is clicked', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This functionality no longer exists. |
||
let utils = {} as RenderResult; | ||
|
||
act(async () => { | ||
utils = render(<Popup />); | ||
}); | ||
|
||
const { queryAllByLabelText, queryByLabelText } = utils; | ||
(chromeHelpers.getActiveColor as jest.Mock).mockResolvedValue(COLORS[0]); | ||
|
||
await waitFor(() => expect(chromeHelpers.getActiveColor).toHaveBeenCalled()); | ||
|
||
const colorButtons = queryAllByLabelText('save color'); | ||
const customColorButton = queryByLabelText('custom color'); | ||
const customForm = queryAllByLabelText('custom form'); | ||
|
||
expect(colorButtons[0]).toHaveClass('colorLinks--button active'); | ||
expect(customForm.length).toEqual(0); | ||
|
||
fireEvent.click(customColorButton); | ||
|
||
waitFor(() => expect(customForm.length).toEqual(1)); | ||
}); | ||
|
||
it('should save a color when a color button is clicked', async () => { | ||
|
@@ -92,12 +47,12 @@ describe('Popup', () => { | |
utils = render(<Popup />); | ||
}); | ||
|
||
const { queryAllByLabelText } = utils; | ||
const { queryAllByLabelText, getAllByTestId } = utils; | ||
(chromeHelpers.getActiveColor as jest.Mock).mockResolvedValue(COLORS[0]); | ||
|
||
await waitFor(() => expect(chromeHelpers.getActiveColor).toHaveBeenCalled()); | ||
|
||
const colorButtons = queryAllByLabelText('save color'); | ||
const colorButtons = getAllByTestId('color button'); | ||
const customForm = queryAllByLabelText('custom form'); | ||
|
||
expect(colorButtons[0]).toHaveClass('colorLinks--button active'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ interface OwnProps { | |
const ColorButton: FC<OwnProps> = ({ color, clickHandler, active }) => ( | ||
<div> | ||
<button | ||
aria-label="save color" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need an |
||
data-testid="color button" | ||
type="button" | ||
className={`colorLinks--button${active ? ' active' : ''}`} | ||
onClick={clickHandler} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom form exists in the DOM now, even when it isn't visible.