-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate tests to testing-library (#3027)
* test: move Box tests to testing-library * feat: move single-target integration tests to testing-library * chore: cut semver doc * feat: update wrapInTestContext to allow for usage with other Backends * refactor: use the act function provided by testing-library * refactor: use wrapWithBackend in box.spec * refactor: update tests to use updated wrapper functions * refactor: move drag sequence simulations into separate module * refactor: use wrapWithBackend in tests * feat: add testing-library drag/drop sequences to utils * test: migrate multi-target integ test in decorators * test: remove enzyme * fix: add @types/node to examples-decorators
- Loading branch information
1 parent
7a89d46
commit 75b37f9
Showing
63 changed files
with
509 additions
and
1,163 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-81.2 KB
.yarn/cache/@wojtekmaj-enzyme-adapter-react-17-npm-0.4.1-a1238067df-8b735856af.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-8.01 KB
.yarn/cache/array.prototype.find-npm-2.1.1-12d8dac121-e786d414ee.zip
Binary file not shown.
Binary file removed
BIN
-4.84 KB
.yarn/cache/discontinuous-range-npm-1.0.0-572abfd975-afc5a30f1a.zip
Binary file not shown.
Binary file removed
BIN
-63.4 KB
.yarn/cache/enzyme-adapter-utils-npm-1.14.0-3639386aab-7105f3bc76.zip
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-6.36 KB
.yarn/cache/enzyme-shallow-equal-npm-1.0.4-208ea272dd-fabf31a440.zip
Binary file not shown.
Binary file removed
BIN
-14.4 KB
.yarn/cache/function.prototype.name-npm-1.1.3-874141c7ae-5311b2c556.zip
Binary file not shown.
Binary file removed
BIN
-7.66 KB
.yarn/cache/functions-have-names-npm-1.2.2-c348c7c2a0-6a23873b0c.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-15.9 KB
.yarn/cache/string.prototype.trim-npm-1.2.3-0b6a08b6ff-4335af32e6.zip
Binary file not shown.
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,8 @@ | ||
releases: | ||
react-dnd-examples-decorators: patch | ||
react-dnd-examples-hooks: patch | ||
react-dnd-html5-backend: patch | ||
react-dnd-test-utils: minor | ||
|
||
declined: | ||
- react-dnd-documentation |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
import '@testing-library/jest-dom' |
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
50 changes: 20 additions & 30 deletions
50
...decorators/src/01-dustbin/multiple-targets/__tests__/multiple-target-integration.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 |
---|---|---|
@@ -1,55 +1,45 @@ | ||
import Example from '..' | ||
import DndDustbin, { DustbinProps } from '../Dustbin' | ||
import DndBox, { BoxProps } from '../Box' | ||
import { | ||
wrapInTestContext, | ||
simulateDragDropSequence, | ||
} from 'react-dnd-test-utils' | ||
import { mount } from 'enzyme' | ||
import { DndComponent as DndC } from 'react-dnd' | ||
import { wrapWithBackend, fireDragDrop } from 'react-dnd-test-utils' | ||
import { render } from '@testing-library/react' | ||
|
||
describe('Dustbin: Multiple Targets', () => { | ||
it('behaves as expected', () => { | ||
const [Wrapped, getBackend] = wrapInTestContext(Example) | ||
const root = mount(<Wrapped />) | ||
it('behaves as expected', async () => { | ||
const TestExample = wrapWithBackend(Example) | ||
const rendered = render(<TestExample />) | ||
|
||
// Verify that all of the key components mounted | ||
const dustbins = root.find(DndDustbin) | ||
const boxes = root.find(DndBox) | ||
const dustbins = await rendered.findAllByRole('Dustbin') | ||
const boxes = await rendered.findAllByRole('Box') | ||
expect(dustbins.length).toEqual(4) | ||
expect(boxes.length).toEqual(3) | ||
|
||
window.alert = jest.fn() | ||
|
||
// Bin Types | ||
const glassBin: DndC<DustbinProps> = dustbins.at(0).instance() as any | ||
const foodBin: DndC<DustbinProps> = dustbins.at(1).instance() as any | ||
// const paperGlassUrlBin: DndC<DustbinProps> = dustbins | ||
// .at(2) | ||
// .instance() as any | ||
// const paperFileBin: DndC<DustbinProps> = dustbins.at(3).instance() as any | ||
const glassBin = dustbins[0] | ||
const foodBin = dustbins[1] | ||
|
||
// Box Types | ||
const bottleBox: DndC<BoxProps> = boxes.at(0).instance() as any | ||
const bananaBox: DndC<BoxProps> = boxes.at(1).instance() as any | ||
// const magazineBox: DndC<BoxProps> = boxes.at(2).instance() as any | ||
const bottleBox = boxes[0] as HTMLDivElement | ||
const bananaBox = boxes[1] | ||
|
||
// interactions | ||
|
||
// drop bottle into glass bin | ||
simulateDragDropSequence(bottleBox, glassBin, getBackend()) | ||
expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name) | ||
await fireDragDrop(bottleBox, glassBin) | ||
expect(glassBin.textContent).toContain(JSON.stringify({ name: 'Bottle' })) | ||
|
||
// food won't drop into the glass bin | ||
simulateDragDropSequence(bananaBox, glassBin, getBackend()) | ||
expect(glassBin.props.lastDroppedItem.name).toEqual(bottleBox.props.name) | ||
await fireDragDrop(bananaBox, glassBin) | ||
expect(glassBin.textContent).toContain(JSON.stringify({ name: 'Bottle' })) | ||
|
||
// glass won't drop into the food box... | ||
simulateDragDropSequence(bottleBox, foodBin, getBackend()) | ||
expect(foodBin.props.lastDroppedItem).toBeNull() | ||
await fireDragDrop(bottleBox, foodBin) | ||
expect(foodBin.textContent).not.toContain('Last dropped') | ||
|
||
// but some food will work | ||
simulateDragDropSequence(bananaBox, foodBin, getBackend()) | ||
expect(foodBin.props.lastDroppedItem.name).toEqual(bananaBox.props.name) | ||
await fireDragDrop(bananaBox, foodBin) | ||
expect(foodBin.textContent).toContain('Last dropped') | ||
expect(foodBin.textContent).toContain(JSON.stringify({ name: 'Banana' })) | ||
}) | ||
}) |
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
Oops, something went wrong.