UNPKG

4.66 kBTypeScriptView Raw
1/// <reference types="enzyme" />
2/// <reference types="chai" />
3/// <reference types="react" />
4/// <reference types="cheerio" />
5
6declare namespace Chai {
7 type EnzymeSelector = string | React.FunctionComponent<any> | React.ComponentClass<any> | { [key: string]: any };
8
9 interface Match {
10 /**
11 * Assert that the wrapper matches given selector:
12 * @param selector
13 */
14 (selector: EnzymeSelector): Assertion;
15 }
16 interface Include {
17 /**
18 * Assert that the wrapper contains a given node:
19 * @param code
20 */
21 (selector: EnzymeSelector): Assertion;
22
23 /**
24 * Assert that the given wrapper has the supplied text:
25 * @param str
26 */
27 text(str?: string): Assertion;
28 }
29 interface Assertion {
30 /**
31 * Assert that the given wrapper is checked:
32 */
33 checked(): Assertion;
34
35 /**
36 * Assert that the wrapper has a given class:
37 * @param name
38 */
39 className(name: string): Assertion;
40
41 /**
42 * Assert that the wrapper contains a certain element:
43 * @param selector
44 */
45 containMatchingElement(selector: EnzymeSelector): Assertion;
46
47 /**
48 * Assert that the wrapper contains a descendant matching the given selector:
49 * @param selector
50 */
51 descendants(selector?: EnzymeSelector): Assertion;
52
53 /**
54 * Assert that the wrapper contains an exact amount of descendants matching the given selector:
55 */
56 exactly(count?: number): Assertion;
57
58 /**
59 * Assert that the given wrapper is disabled:
60 */
61 disabled(): Assertion;
62
63 /**
64 * Assert that the given wrapper is empty:
65 */
66 blank(): Assertion;
67
68 /**
69 * Assert that the given wrapper exists:
70 */
71 present(): Assertion;
72
73 /**
74 * Assert that the wrapper has given html:
75 * @param str
76 */
77 html(str?: string): Assertion;
78
79 /**
80 * Assert that the wrapper has given ID attribute:
81 * @param str
82 */
83 id(str: string): Assertion;
84
85 /**
86 * Assert that the wrapper has a given ref
87 * @param key
88 */
89 ref(key: string): Assertion;
90
91 /**
92 * Assert that the given wrapper is selected:
93 */
94 selected(): Assertion;
95
96 /**
97 * Assert that the given wrapper has the tag name:
98 * @param str
99 */
100 tagName(str: string): Assertion;
101
102 /**
103 * Assert that the given wrapper has the supplied text:
104 * @param str
105 */
106 text(str?: string): Assertion;
107
108 /**
109 * Assert that the given wrapper has a given type:
110 * @param func
111 */
112 type(func: EnzymeSelector): Assertion;
113
114 /**
115 * Assert that the given wrapper has given value:
116 * @param str
117 */
118 value(str: string): Assertion;
119
120 /**
121 * Assert that the wrapper has given attribute [with value]:
122 * @param key
123 * @param val
124 */
125 attr(key: string, val?: string): Assertion;
126
127 /**
128 * Assert that the wrapper has a given data attribute [with value]:
129 * @param key
130 * @param val
131 */
132 data(key: string, val?: string): Assertion;
133
134 /**
135 * Assert that the wrapper has given style:
136 * @param key
137 * @param val
138 */
139 style(key: string, val?: string): Assertion;
140
141 /**
142 * Assert that the wrapper has given state [with value]:
143 * @param key
144 * @param val
145 */
146 state(key: string, val?: any): Assertion;
147
148 /**
149 * Assert that the wrapper has given prop [with value]:
150 * @param key
151 * @param val
152 */
153 prop(key: string, val?: any): Assertion;
154
155 /**
156 * Assert that the wrapper has given props [with values]:
157 * @param keys
158 */
159 props(keys: string[]): Assertion;
160
161 /**
162 * Assert that the wrapper has given props [with values]:
163 * @param props
164 */
165 props(props: EnzymeSelector): Assertion;
166 }
167}
168
169declare module "chai-enzyme" {
170 import { ReactWrapper, ShallowWrapper } from "enzyme";
171
172 type DebugWrapper = ShallowWrapper<any, any> | cheerio.Cheerio | ReactWrapper<any, any>;
173 function chaiEnzyMe(wrapper?: (debugWrapper: DebugWrapper) => string): Chai.ChaiPlugin;
174
175 namespace chaiEnzyMe {
176 }
177 export = chaiEnzyMe;
178}