-
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.
Add initial tests to drag-around examples (#3032)
* chore: upgrade dependencies * test: add tests for drag-around-naive scenario * test: add tests to CustomDraglayer * chore: cut semver doc * fix: add @types/react resolutions * fix: remove unused imports
- Loading branch information
1 parent
75b37f9
commit 2ba22bf
Showing
78 changed files
with
1,422 additions
and
1,288 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file renamed
BIN
+61.9 KB
...ore-npm-7.12.13-63c8ede804-c8cb571261.zip → ...ore-npm-7.12.16-7fadc67d1e-87b621eb25.zip
Binary file not shown.
Binary file removed
BIN
-8.56 KB
.yarn/cache/@babel-helper-compilation-targets-npm-7.12.13-4561a54274-4b91f74325.zip
Binary file not shown.
Binary file added
BIN
+7.72 KB
.yarn/cache/@babel-helper-compilation-targets-npm-7.12.16-4df763be91-3eadb8722a.zip
Binary file not shown.
Binary file renamed
BIN
+13.9 KB
...gin-npm-7.12.13-e6c461ee3f-dfb86b2d5c.zip → ...gin-npm-7.12.16-171d9bb3bb-535bdbbde5.zip
Binary file not shown.
Binary file removed
BIN
-4.9 KB
...n/cache/@babel-helper-create-regexp-features-plugin-npm-7.12.13-7691ff96c7-709f491bb6.zip
Binary file not shown.
Binary file added
BIN
+4.06 KB
...n/cache/@babel-helper-create-regexp-features-plugin-npm-7.12.16-517f3b580d-f1fd81069e.zip
Binary file not shown.
Binary file removed
BIN
-13.8 KB
.../cache/@babel-helper-member-expression-to-functions-npm-7.12.13-b4563cc5d5-64827b3c56.zip
Binary file not shown.
Binary file added
BIN
+13 KB
.../cache/@babel-helper-member-expression-to-functions-npm-7.12.16-5c10642696-d4c86c2686.zip
Binary file not shown.
Binary file removed
BIN
-3.77 KB
.yarn/cache/@babel-helper-validator-option-npm-7.12.11-a3c58ccc52-c0a861e95f.zip
Binary file not shown.
Binary file added
BIN
+2.96 KB
.yarn/cache/@babel-helper-validator-option-npm-7.12.16-9fbfc14080-df6c04030a.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-3.17 KB
.yarn/cache/@babel-plugin-proposal-dynamic-import-npm-7.12.1-b81c2ca860-4428439b48.zip
Binary file not shown.
Binary file added
BIN
+2.33 KB
.yarn/cache/@babel-plugin-proposal-dynamic-import-npm-7.12.16-aa7e36e16b-1f8c653eeb.zip
Binary file not shown.
Binary file removed
BIN
-10.6 KB
.yarn/cache/@babel-plugin-proposal-optional-chaining-npm-7.12.13-f78fa9ee1b-40e7ba4986.zip
Binary file not shown.
Binary file added
BIN
+9.78 KB
.yarn/cache/@babel-plugin-proposal-optional-chaining-npm-7.12.16-691e2d4d05-599e90b119.zip
Binary file not shown.
Binary file removed
BIN
-2.43 KB
...cache/@babel-plugin-transform-react-jsx-development-npm-7.12.12-5bfa52a758-c9d320ba13.zip
Binary file not shown.
Binary file added
BIN
+1.59 KB
...cache/@babel-plugin-transform-react-jsx-development-npm-7.12.16-179d792fa4-1e428b007a.zip
Binary file not shown.
Binary file renamed
BIN
+7.83 KB
...jsx-npm-7.12.13-400edb643c-06a914c912.zip → ...jsx-npm-7.12.16-c7baa496b1-116dbf212d.zip
Binary file not shown.
Binary file renamed
BIN
+8.91 KB
...ipt-npm-7.12.13-8937b106b3-92fdd46da9.zip → ...ipt-npm-7.12.16-a8720f8162-cb42a4d548.zip
Binary file not shown.
Binary file renamed
BIN
+33.2 KB
...env-npm-7.12.13-fec1721be1-6121a54742.zip → ...env-npm-7.12.16-5c27c40532-5b949e9b21.zip
Binary file not shown.
Binary file removed
BIN
-4.93 KB
.yarn/cache/@babel-preset-typescript-npm-7.12.13-af44b223a6-d4a8824acf.zip
Binary file not shown.
Binary file added
BIN
+4.14 KB
.yarn/cache/@babel-preset-typescript-npm-7.12.16-ccc544ed52-761a01c754.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+6.47 KB
...eady-npm-1.0.10-f29da0aad5-8da7344e3c.zip → ...eady-npm-1.0.11-56778f292c-acabb0b8c4.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 renamed
BIN
+642 KB
...pm-1.0.30001185-d0474578ac-35a6087bfe.zip → ...pm-1.0.30001187-1dcc285f44-788d977269.zip
Binary file not shown.
Binary file renamed
BIN
+11.4 KB
...ium-npm-1.3.662-4d28a171d9-d2a9c34229.zip → ...ium-npm-1.3.664-9eb58b125c-ae3705e898.zip
Binary file not shown.
Binary file renamed
BIN
+849 KB
...lint-npm-7.19.0-796aed1841-0461e8b2b5.zip → ...lint-npm-7.20.0-42a38efe95-1d56cabc7e.zip
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+14.5 KB
.../open-npm-7.4.0-4ea39c72e6-cb3ca8bc36.zip → .../open-npm-7.4.1-9fb9d653f9-dbd78f805e.zip
Binary file not shown.
Binary file renamed
BIN
+53.4 KB
...olve-npm-1.19.0-1c75f25c98-8b23c7fde1.zip → ...olve-npm-1.20.0-1bc5878aa9-0f5206d454.zip
Binary file not shown.
Binary file renamed
BIN
+54.6 KB
...e/resolve-patch-46f4fba2f6-188d5167e8.zip → ...e/resolve-patch-55fcdb097c-c4a515b760.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 renamed
BIN
+29.2 KB
...rser-npm-20.2.4-1de20916a6-00dd0f23b6.zip → ...rser-npm-20.2.5-cc6ec6e915-4b558eb7d4.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,9 @@ | ||
releases: | ||
react-dnd-test-utils: patch | ||
|
||
declined: | ||
- "@react-dnd/build" | ||
- react-dnd-documentation | ||
- react-dnd-examples-decorators | ||
- react-dnd-examples-hooks | ||
- react-dnd |
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
40 changes: 40 additions & 0 deletions
40
...oks/src/02-drag-around/custom-drag-layer/__tests__/custom-drag-layer-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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Example from '../index' | ||
import { act, fireEvent, render } from '@testing-library/react' | ||
import { wrapWithBackend, tick } from 'react-dnd-test-utils' | ||
|
||
describe('Drag Around: Custom Drag Layer', () => { | ||
it('toggles the overlay layer over time', async () => { | ||
jest.useFakeTimers() | ||
const TestExample = wrapWithBackend(Example) | ||
const rendered = render(<TestExample />) | ||
const draggableBoxes = await rendered.findAllByRole('DraggableBox') | ||
expect(draggableBoxes).toHaveLength(2) | ||
const first = draggableBoxes[0] | ||
const second = draggableBoxes[1] | ||
|
||
// Dragging a box hides it | ||
let tickAwait: Promise<void> | ||
await act(async () => { | ||
fireEvent.dragStart(first) | ||
tickAwait = tick() | ||
jest.advanceTimersByTime(10) | ||
await tickAwait | ||
}) | ||
|
||
expect(first).toHaveStyle({ opacity: 0 }) | ||
expect(second).toHaveStyle({ opacity: 1 }) | ||
|
||
const preview = await rendered.findByRole('Box-Preview') | ||
expect(preview).toHaveStyle({ backgroundColor: 'white' }) | ||
|
||
act(() => { | ||
jest.advanceTimersByTime(501) | ||
}) | ||
expect(preview).toHaveStyle({ backgroundColor: 'yellow' }) | ||
|
||
act(() => { | ||
jest.advanceTimersByTime(501) | ||
}) | ||
expect(preview).toHaveStyle({ backgroundColor: 'white' }) | ||
}) | ||
}) |
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: 50 additions & 0 deletions
50
.../examples-hooks/src/02-drag-around/naive/__tests__/drag-around-naive-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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Example from '../index' | ||
import { fireEvent, render } from '@testing-library/react' | ||
import { | ||
wrapWithBackend, | ||
fireDrag, | ||
fireReleaseDrag, | ||
tick, | ||
} from 'react-dnd-test-utils' | ||
|
||
describe('Drag Around: Naive', () => { | ||
it('can hide the source node on drag', async () => { | ||
const TestExample = wrapWithBackend(Example) | ||
const rendered = render(<TestExample />) | ||
const getBoxes = () => rendered.findAllByRole('Box') | ||
const boxes = await getBoxes() | ||
expect(boxes.length).toEqual(2) | ||
const first = boxes[0] | ||
|
||
// Dragging a box hides it | ||
await fireDrag(first) | ||
await tick() | ||
expect(await getBoxes()).toHaveLength(1) | ||
|
||
// Dropping the box shows it again | ||
await fireReleaseDrag(first) | ||
expect(await getBoxes()).toHaveLength(2) | ||
}) | ||
|
||
it('can disable source hiding', async () => { | ||
const TestExample = wrapWithBackend(Example) | ||
const rendered = render(<TestExample />) | ||
const getBoxes = () => rendered.findAllByRole('Box') | ||
const boxes = await getBoxes() | ||
const checkbox = await rendered.findByRole('checkbox') | ||
expect(boxes.length).toEqual(2) | ||
const first = boxes[0] | ||
|
||
// disable source hiding | ||
await fireEvent.click(checkbox) | ||
|
||
// Drag a box | ||
await fireDrag(first) | ||
await tick() | ||
expect(await getBoxes()).toHaveLength(2) | ||
|
||
// Drop the box | ||
await fireReleaseDrag(first) | ||
expect(await getBoxes()).toHaveLength(2) | ||
}) | ||
}) |
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
Oops, something went wrong.