forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-addons-test-utils.d.ts
172 lines (154 loc) · 6.9 KB
/
react-addons-test-utils.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// Type definitions for React v0.14 (react-addons-test-utils)
// Project: http://facebook.github.io/react/
// Definitions by: Asana <https://asana.com>, AssureSign <http://www.assuresign.com>, Microsoft <https://microsoft.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="react.d.ts" />
declare namespace __React {
interface OptionalEventProperties {
bubbles?: boolean;
cancelable?: boolean;
currentTarget?: EventTarget;
defaultPrevented?: boolean;
eventPhase?: number;
isTrusted?: boolean;
nativeEvent?: Event;
preventDefault?(): void;
stopPropagation?(): void;
target?: EventTarget;
timeStamp?: Date;
type?: string;
}
interface SyntheticEventData extends OptionalEventProperties {
altKey?: boolean;
button?: number;
buttons?: number;
clientX?: number;
clientY?: number;
changedTouches?: TouchList;
charCode?: boolean;
clipboardData?: DataTransfer;
ctrlKey?: boolean;
deltaMode?: number;
deltaX?: number;
deltaY?: number;
deltaZ?: number;
detail?: number;
getModifierState?(key: string): boolean;
key?: string;
keyCode?: number;
locale?: string;
location?: number;
metaKey?: boolean;
pageX?: number;
pageY?: number;
relatedTarget?: EventTarget;
repeat?: boolean;
screenX?: number;
screenY?: number;
shiftKey?: boolean;
targetTouches?: TouchList;
touches?: TouchList;
view?: AbstractView;
which?: number;
}
interface EventSimulator {
(element: Element | Component<any, any>, eventData?: SyntheticEventData): void;
}
interface MockedComponentClass {
new(): any;
}
class ShallowRenderer {
getRenderOutput<E extends ReactElement<any>>(): E;
getRenderOutput(): ReactElement<any>;
render(element: ReactElement<any>, context?: any): void;
unmount(): void;
}
namespace __Addons {
namespace TestUtils {
namespace Simulate {
export var blur: EventSimulator;
export var change: EventSimulator;
export var click: EventSimulator;
export var copy: EventSimulator;
export var cut: EventSimulator;
export var doubleClick: EventSimulator;
export var drag: EventSimulator;
export var dragEnd: EventSimulator;
export var dragEnter: EventSimulator;
export var dragExit: EventSimulator;
export var dragLeave: EventSimulator;
export var dragOver: EventSimulator;
export var dragStart: EventSimulator;
export var drop: EventSimulator;
export var focus: EventSimulator;
export var input: EventSimulator;
export var keyDown: EventSimulator;
export var keyPress: EventSimulator;
export var keyUp: EventSimulator;
export var mouseDown: EventSimulator;
export var mouseEnter: EventSimulator;
export var mouseLeave: EventSimulator;
export var mouseMove: EventSimulator;
export var mouseOut: EventSimulator;
export var mouseOver: EventSimulator;
export var mouseUp: EventSimulator;
export var paste: EventSimulator;
export var scroll: EventSimulator;
export var submit: EventSimulator;
export var touchCancel: EventSimulator;
export var touchEnd: EventSimulator;
export var touchMove: EventSimulator;
export var touchStart: EventSimulator;
export var wheel: EventSimulator;
}
export function renderIntoDocument<T extends Element>(
element: DOMElement<any, T>): T;
export function renderIntoDocument(
element: SFCElement<any>): void;
export function renderIntoDocument<T extends Component<any, any>>(
element: CElement<any, T>): T;
export function renderIntoDocument<P>(
element: ReactElement<P>): Component<P, {}> | Element | void;
export function mockComponent(
mocked: MockedComponentClass, mockTagName?: string): typeof TestUtils;
export function isElementOfType<T extends HTMLElement>(
element: ReactElement<any>, type: string): element is ReactHTMLElement<T>;
export function isElementOfType<P extends DOMAttributes, T extends Element>(
element: ReactElement<any>, type: string): element is DOMElement<P, T>;
export function isElementOfType<P>(
element: ReactElement<any>, type: SFC<P>): element is SFCElement<P>;
export function isElementOfType<P, T extends Component<P, {}>, C extends ComponentClass<P>>(
element: ReactElement<any>, type: ClassType<P, T, C>): element is CElement<P, T>;
export function isDOMComponent(instance: ReactInstance): instance is Element;
export function isCompositeComponent(instance: ReactInstance): instance is Component<any, any>;
export function isCompositeComponentWithType<T extends Component<any, any>, C extends ComponentClass<any>>(
instance: ReactInstance, type: ClassType<any, T, C>): T;
export function findAllInRenderedTree(
root: Component<any, any>,
fn: (i: ReactInstance) => boolean): ReactInstance[];
export function scryRenderedDOMComponentsWithClass(
root: Component<any, any>,
className: string): Element[];
export function findRenderedDOMComponentWithClass(
root: Component<any, any>,
className: string): Element;
export function scryRenderedDOMComponentsWithTag(
root: Component<any, any>,
tagName: string): Element[];
export function findRenderedDOMComponentWithTag(
root: Component<any, any>,
tagName: string): Element;
export function scryRenderedComponentsWithType<T extends Component<{}, {}>, C extends ComponentClass<{}>>(
root: Component<any, any>,
type: ClassType<any, T, C>): T[];
export function findRenderedComponentWithType<T extends Component<{}, {}>, C extends ComponentClass<{}>>(
root: Component<any, any>,
type: ClassType<any, T, C>): T;
export function createRenderer(): ShallowRenderer;
}
}
}
declare module "react-addons-test-utils" {
import TestUtils = __React.__Addons.TestUtils;
export = TestUtils;
}