-
Notifications
You must be signed in to change notification settings - Fork 64
/
index.d.ts
64 lines (54 loc) · 2.42 KB
/
index.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
/// <reference types="cheerio" />
import {CommonWrapper, ShallowWrapper, ReactWrapper} from 'enzyme';
export interface Json {
type: string;
props: {[key: string]: any};
children: Array<Json>;
$$typeof: Symbol;
}
export interface OutputMapper {
(json: Json): Json;
}
export interface Options {
ignoreDefaultProps?: boolean;
map?: OutputMapper;
noKey?: boolean;
mode?: 'shallow' | 'deep';
}
export interface JestSerializer {
test: (CommonWrapper: CommonWrapper) => boolean;
print: (CommonWrapper: CommonWrapper, serializer: JestSerializer) => Json;
}
/**
* toJson helper is used to convert any Enzyme wrapper to a format compatible with Jest snapshot
* @param wrapper any Enzyme wrapper
* @param [options] an option object which accepts `map`, `noKey` and `mode` as keys
*/
export declare function toJson(wrapper: CommonWrapper | cheerio.Cheerio, options?: Options): Json;
export declare function toJson<P, S>(wrapper: CommonWrapper<P, S> | cheerio.Cheerio, options?: Options): Json;
/**
* shallowToJson helper is used to convert Enzyme shallow wrappers to a format compatible with Jest snapshot
* @param wrapper an Enzyme shallow wrapper
* @param [options] an option object which accepts `map`, `noKey` and `mode` as keys
*/
export declare function shallowToJson(wrapper: ShallowWrapper, options?: Options,): Json;
export declare function shallowToJson<P, S>(wrapper: ShallowWrapper<P, S>, options?: Options,): Json;
/**
* mountToJson helper is used to convert Enzyme mount wrappers to a format compatible with Jest snapshot
* @param wrapper an Enzyme mount wrapper
* @param [options] an option object which accepts `map`, `noKey` and `mode` as keys
*/
export declare function mountToJson(wrapper: ReactWrapper, options?: Options): Json;
export declare function mountToJson<P, S>(wrapper: ReactWrapper<P, S>, options?: Options): Json;
/**
* renderToJson helper is used to convert Enzyme render wrappers to a format compatible with Jest snapshot
* @param wrapper an Enzyme render wrapper
* @param [options] an option object which accepts `map`, `noKey` and `mode` as keys
*/
export declare function renderToJson(wrapper: cheerio.Cheerio, options?: Options): Json;
/**
* createSerializer helper is used to create snapshot serializers for Jest
* @param [options] an option object which accepts `map`, `noKey` and `mode` as keys
*/
export declare function createSerializer(options?: Options): JestSerializer;
export default toJson;