Add react-dnd-test-backend

This commit is contained in:
Gustavo Henke
2017-12-19 16:29:06 +11:00
parent 571e108a79
commit 5f5c9be6f3
4 changed files with 63 additions and 0 deletions

15
types/react-dnd-test-backend/index.d.ts vendored Normal file
View File

@@ -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 <https://github.com/gustavohenke>
// 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;
}

View File

@@ -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)(() => <div/>);
<Component ref={(instance: ContextComponent<{}, {}>) => {
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();
}}/>;

View File

@@ -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"
]
}

View File

@@ -0,0 +1,6 @@
{
"extends": "dtslint/dt.json",
"rules": {
"quotemark": [true, "double"]
}
}