@@ -6,24 +6,184 @@ import { UserEvents } from './user-events';
6
6
export type RenderResultQueries < Q extends Queries = typeof queries > = { [ P in keyof Q ] : BoundFunction < Q [ P ] > } ;
7
7
8
8
export interface RenderResult extends RenderResultQueries , FireObject , UserEvents {
9
+ /**
10
+ * @description
11
+ * The HTML of the rendered component
12
+ */
9
13
container : HTMLElement ;
14
+ /**
15
+ * @description
16
+ * Prints out the component's HTML with syntax highlighting
17
+ *
18
+ * @param
19
+ * element: The to be printed HTML element, if not provided it will log the whole component's HTML
20
+ */
10
21
debug : ( element ?: HTMLElement ) => void ;
22
+ /**
23
+ * @description
24
+ * The Angular `ComponentFixture` of the component
25
+ * For more info see https://angular.io/api/core/testing/ComponentFixture
26
+ */
11
27
fixture : ComponentFixture < any > ;
12
28
}
13
29
14
30
export interface RenderOptions < C , Q extends Queries = typeof queries > {
31
+ /**
32
+ * @description
33
+ * Will call detectChanges when the component is compiled
34
+ *
35
+ * @default
36
+ * true
37
+ *
38
+ * @example
39
+ * const component = render(AppComponent, {
40
+ * detectChanges: false
41
+ * })
42
+ */
15
43
detectChanges ?: boolean ;
44
+ /**
45
+ * @description
46
+ * A collection of components, directives and pipes needed to render the component, for example, nested components of the component
47
+ * For more info see https://angular.io/api/core/NgModule#declarations
48
+ *
49
+ * @default
50
+ * []
51
+ *
52
+ * @example
53
+ * const component = render(AppComponent, {
54
+ * declarations: [ CustomerDetailComponent, ButtonComponent ]
55
+ * })
56
+ */
16
57
declarations ?: any [ ] ;
58
+ /**
59
+ * @description
60
+ * A collection of providers needed to render the component via Dependency Injection, for example, injectable services or tokens
61
+ * For more info see https://angular.io/api/core/NgModule#providers
62
+ *
63
+ * @default
64
+ * []
65
+ *
66
+ * @example
67
+ * const component = render(AppComponent, {
68
+ * providers: [
69
+ * CustomersService,
70
+ * {
71
+ * provide: MAX_CUSTOMERS_TOKEN,
72
+ * useValue: 10
73
+ * }
74
+ * ]
75
+ * })
76
+ */
17
77
providers ?: any [ ] ;
78
+ /**
79
+ * @description
80
+ * A collection of imports needed to render the component, for example, shared modules
81
+ * For more info see https://angular.io/api/core/NgModule#imports
82
+ *
83
+ * @default
84
+ * Adds `NoopAnimationsModule` by default if `BrowserAnimationsModule` isn't added to the collection:
85
+ * `[NoopAnimationsModule]`
86
+ *
87
+ * @example
88
+ * const component = render(AppComponent, {
89
+ * providers: [
90
+ * AppSharedModule,
91
+ * MaterialModule,
92
+ * ]
93
+ * })
94
+ */
18
95
imports ?: any [ ] ;
96
+ /**
97
+ * @description
98
+ * A collection of schemas needed to render the component.
99
+ * Allowed value are `NO_ERRORS_SCHEMA` and `CUSTOM_ELEMENTS_SCHEMA`.
100
+ * For more info see https://angular.io/api/core/NgModule#schemas
101
+ *
102
+ * @default
103
+ * []
104
+ *
105
+ * @example
106
+ * const component = render(AppComponent, {
107
+ * imports: [
108
+ * NO_ERRORS_SCHEMA,
109
+ * ]
110
+ * })
111
+ */
19
112
schemas ?: any [ ] ;
113
+ /**
114
+ * @description
115
+ * An object to set `@Input` and `@Output` properties of the component
116
+ *
117
+ * @default
118
+ * {}
119
+ *
120
+ * @example
121
+ * const component = render(AppComponent, {
122
+ * componentProperties: {
123
+ * counterValue: 10,
124
+ * send: (value) => { ... }
125
+ * }
126
+ * })
127
+ */
20
128
componentProperties ?: Partial < C > ;
129
+ /**
130
+ * @description
131
+ * A collection of providers to inject dependencies of the component
132
+ * For more info see https://angular.io/api/core/Directive#providers
133
+ *
134
+ * @default
135
+ * []
136
+ *
137
+ * @example
138
+ * const component = render(AppComponent, {
139
+ * componentProviders: [
140
+ * AppComponentService
141
+ * ]
142
+ * })
143
+ */
21
144
componentProviders ?: any [ ] ;
145
+ /**
146
+ * @description
147
+ * Queries to bind. Overrides the default set from DOM Testing Library unless merged.
148
+ *
149
+ * @default
150
+ * undefined
151
+ *
152
+ * @example
153
+ * import * as customQueries from 'custom-queries'
154
+ * import { queries } from '@testing-library/angular'
155
+ *
156
+ * const component = render(AppComponent, {
157
+ * queries: { ...queries, ...customQueries }
158
+ * })
159
+ */
22
160
queries ?: Q ;
161
+ /**
162
+ * @description
163
+ * An Angular component to wrap the component in
164
+ *
165
+ * @default
166
+ * `WrapperComponent`, an empty component that strips the `ng-version` attribute
167
+ *
168
+ * @example
169
+ * const component = render(AppComponent, {
170
+ * wrapper: CustomWrapperComponent
171
+ * })
172
+ */
23
173
wrapper ?: Type < any > ;
24
174
/**
25
- * Exclude the component to be automatically be added as a declaration
26
- * This is needed when the component is declared in an imported module
175
+ * @description
176
+ * Exclude the component to be automatically be added as a declaration.
177
+ * This is needed when the component is declared in an imported module.
178
+ *
179
+ * @default
180
+ * false
181
+ *
182
+ * @example
183
+ * const component = render(AppComponent, {
184
+ * imports: [AppModule], // a module that includes AppComponent
185
+ * excludeComponentDeclaration: true
186
+ * })
27
187
*/
28
188
excludeComponentDeclaration ?: boolean ;
29
189
}
0 commit comments