diff --git a/types/react-dnd-test-backend/index.d.ts b/types/react-dnd-test-backend/index.d.ts new file mode 100644 index 0000000000..07f13607dd --- /dev/null +++ b/types/react-dnd-test-backend/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for react-dnd-test-backend 2.5 +// Project: https://github.com/react-dnd/react-dnd#readme +// Definitions by: Gustavo Henke +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import * as ReactDnd from "react-dnd"; + +export default class TestBackend implements ReactDnd.Backend { + simulateBeginDrag(sourceIds: ReactDnd.Identifier[], options?: {}): void; + simulatePublishDragSource(): void; + simulateHover(targetIds: ReactDnd.Identifier[], options?: {}): void; + simulateDrop(): void; + simulateEndDrag(): void; +} diff --git a/types/react-dnd-test-backend/react-dnd-test-backend-tests.tsx b/types/react-dnd-test-backend/react-dnd-test-backend-tests.tsx new file mode 100644 index 0000000000..aed3117e06 --- /dev/null +++ b/types/react-dnd-test-backend/react-dnd-test-backend-tests.tsx @@ -0,0 +1,17 @@ +import * as React from "react"; +import { ContextComponent, ContextComponentClass, DragDropContext } from "react-dnd"; +import TestBackend from "react-dnd-test-backend"; + +const Component = DragDropContext(TestBackend)(() =>
); +) => { + const backend = instance.getManager().getBackend() as TestBackend; + backend.simulateBeginDrag(["1"]); + backend.simulateBeginDrag(["1"], { foo: "bar" }); + + backend.simulateHover(["2"]); + backend.simulateHover(["2"], { foo: "bar" }); + + backend.simulateDrop(); + backend.simulateEndDrag(); + backend.simulatePublishDragSource(); +}}/>; diff --git a/types/react-dnd-test-backend/tsconfig.json b/types/react-dnd-test-backend/tsconfig.json new file mode 100644 index 0000000000..aaf674e57e --- /dev/null +++ b/types/react-dnd-test-backend/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-dnd-test-backend-tests.tsx" + ] +} diff --git a/types/react-dnd-test-backend/tslint.json b/types/react-dnd-test-backend/tslint.json new file mode 100644 index 0000000000..8b04e2b32d --- /dev/null +++ b/types/react-dnd-test-backend/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "quotemark": [true, "double"] + } +}