-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate enzyme to testing library (#586)
* Set up React Testing Library * Migrate Spinner * convert button tests from enzyme to rtl * remove unused imports * remove unused import * Update jest and set test environment to jsdom * Bump version * update checkbox.test.js tests * checkbox.test.js and checkbox-group.test.js complete * update button.test.js to use userevent * update color-input.test.js to rtl * remove unused imports * update date input * complete color-input and date-input * complete dropdown-checkbox-group * complete hidden input * complete icon-input * Fix date input issues * RTL migration: controls (#602) * Migrate paginator * Add comment * Remove unused import * Migrate tab-bar * RTL migration: modal (#601) * Initial commit * Clean up logs * Add tests more default close interactions * RTL migration: indicators (#600) * Migrate loading container * Migrate flash message * Migrate flash message container * Upgdate assertion * Partial cleanup; Address code review * Remove unecessary test * Remove moment dependency from DateInput test * Update ColorPicker component * Update DropdownCheckboxGroup * Update HiddenInput * Update IconInput * Update Spinner component * Bump minor version * Address comments * Fix trigger on keys util * Migrate color-picker * RTL migration: tables (#603) * RTL migration: labels (#607) * partial label folder tests * Clean up error label * Fix input error tests * Remove unused attribute * Fix input label tests * Migrate labeled-field tests * Fixes --------- Co-authored-by: Alex Jin <[email protected]> * RTL migration: inputs (#604) * Migrate input * Migrate textarea * Remove unused import * Migrate switch * Remove unused import * Migrate range-input * Migrate select * Migrate masked input * Migrate replace empty string value hoc * Migrate blur dirty * Migrate radio group input * Migrate cloudinary uploader * Be more explicit * Use toHaveAttribute * Do not reference id directly * RTL migration: file inputs (#590) * Migrate FileInput to RTL * Migrate CloudinaryFileInput to RTL --------- Co-authored-by: Conor <[email protected]> * Remove enzyme * Add act back to file input * Avoid race conditions with act * Update lock * Add test for read helper * Mock server...better * Address uncovered line in wrap-display-name * Remove unused default * Add coverage for modal * Increase dropdown select coverage * Increase color picker coverage * Increase color-input coverage * Increase to-hex coverage * Increase paginator coverage * Increase masked input coverage * Increase date input coverage * Increase radio group coverage * Improve cloudinary-uploader coverage * Improve coverage for getEnvVar * Improve sortable table coverage * Improve tab-bar coverage * Update trigger on keys * Add comment * Replace act with waitFor --------- Co-authored-by: Alex Jin <[email protected]> Co-authored-by: Conor Hawes <[email protected]>
- Loading branch information
1 parent
f5146b3
commit c3bf628
Showing
57 changed files
with
2,889 additions
and
1,881 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,7 @@ module.exports = { | |
node: false, | ||
'shared-node-browser': true, | ||
}, | ||
globals: { | ||
File: true, | ||
}, | ||
} |
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
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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
module.exports = { | ||
testEnvironment: 'jsdom', | ||
'setupFiles': [ | ||
'./test/setup.js', | ||
], | ||
"watchPathIgnorePatterns": [ | ||
"<rootDir>/node_modules", | ||
] | ||
} | ||
setupFilesAfterEnv: ['./test/setup.js'], | ||
watchPathIgnorePatterns: ['<rootDir>/node_modules'], | ||
} |
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
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
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
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,19 +1,50 @@ | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import { render, screen, waitForElementToBeRemoved } from '@testing-library/react' | ||
import userEvent from '@testing-library/user-event' | ||
import { ColorPicker } from '../../src/' | ||
|
||
test('ColorPicker toggles expanded when swatch is clicked', () => { | ||
const wrapper = mount(<ColorPicker />) | ||
expect(wrapper.find('.popover').exists()).toBe(false) | ||
wrapper.find('.swatch').simulate('click') | ||
expect(wrapper.find('.popover').exists()).toBe(true) | ||
wrapper.find('.swatch').simulate('click') | ||
expect(wrapper.find('.popover').exists()).toBe(false) | ||
test('ColorPicker toggles expanded when swatch is clicked', async () => { | ||
const user = userEvent.setup() | ||
render(<ColorPicker />) | ||
const swatchControl = screen.getByRole('button') | ||
|
||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument() | ||
await user.click(swatchControl) | ||
expect(screen.queryByRole('dialog')).toBeInTheDocument() | ||
await user.click(swatchControl) | ||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument() | ||
}) | ||
|
||
test('ColorPicker can be externally controlled', () => { | ||
const wrapper = mount(<ColorPicker active={true} />) | ||
expect(wrapper.find('.popover').exists()).toBe(true) | ||
wrapper.setProps({ active: false }) | ||
expect(wrapper.find('.popover').exists()).toBe(false) | ||
const { rerender } = render(<ColorPicker active={true} />) | ||
|
||
expect(screen.queryByRole('dialog')).toBeInTheDocument() | ||
rerender(<ColorPicker active={false} />) | ||
expect(screen.queryByRole('dialog')).not.toBeInTheDocument() | ||
}) | ||
|
||
test('ColorPicker closes when a click is registered outside', async () => { | ||
const user = userEvent.setup() | ||
const { container } = render(<ColorPicker />) | ||
const swatchControl = screen.getByRole('button') | ||
|
||
await user.click(swatchControl) | ||
expect(screen.queryByRole('dialog')).toBeInTheDocument() | ||
|
||
user.click(container) | ||
await waitForElementToBeRemoved(screen.queryByRole('dialog')) | ||
}) | ||
|
||
test('ColorPicker calls on change with a hex value', async () => { | ||
const user = userEvent.setup() | ||
const mock = jest.fn() | ||
render(<ColorPicker onChange={mock} />) | ||
const swatchControl = screen.getByRole('button') | ||
|
||
await user.click(swatchControl) | ||
const input = screen.getByRole('textbox') | ||
await user.clear(input) | ||
await user.type(input, '639') | ||
|
||
expect(mock).toHaveBeenCalledWith('#663399') | ||
}) |
Oops, something went wrong.