ngx-speculoos 6.0.0 → 7.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -42
- package/esm2020/jasmine-matchers.mjs +2 -0
- package/esm2020/lib/component-tester.mjs +147 -0
- package/esm2020/lib/matchers.mjs +283 -0
- package/esm2020/lib/mock.mjs +25 -0
- package/esm2020/lib/route.mjs +319 -0
- package/{esm2015/lib/test-button.js → esm2020/lib/test-button.mjs} +0 -0
- package/esm2020/lib/test-element-querier.mjs +140 -0
- package/esm2020/lib/test-element.mjs +142 -0
- package/{esm2015/lib/test-html-element.js → esm2020/lib/test-html-element.mjs} +0 -0
- package/{esm2015/lib/test-input.js → esm2020/lib/test-input.mjs} +0 -0
- package/{esm2015/lib/test-select.js → esm2020/lib/test-select.mjs} +0 -0
- package/{esm2015/lib/test-textarea.js → esm2020/lib/test-textarea.mjs} +0 -0
- package/{esm2015/ngx-speculoos.js → esm2020/ngx-speculoos.mjs} +0 -0
- package/{esm2015/public_api.js → esm2020/public_api.mjs} +2 -1
- package/fesm2015/ngx-speculoos.mjs +1257 -0
- package/fesm2015/ngx-speculoos.mjs.map +1 -0
- package/{fesm2015/ngx-speculoos.js → fesm2020/ngx-speculoos.mjs} +436 -22
- package/fesm2020/ngx-speculoos.mjs.map +1 -0
- package/jasmine-matchers.d.ts +5 -0
- package/lib/component-tester.d.ts +87 -49
- package/lib/mock.d.ts +10 -0
- package/lib/route.d.ts +149 -0
- package/lib/test-element-querier.d.ts +15 -15
- package/lib/test-element.d.ts +87 -49
- package/package.json +24 -11
- package/public_api.d.ts +1 -0
- package/bundles/ngx-speculoos.umd.js +0 -1259
- package/bundles/ngx-speculoos.umd.js.map +0 -1
- package/esm2015/jasmine-matchers.js +0 -2
- package/esm2015/lib/component-tester.js +0 -96
- package/esm2015/lib/matchers.js +0 -244
- package/esm2015/lib/route.js +0 -81
- package/esm2015/lib/test-element-querier.js +0 -129
- package/esm2015/lib/test-element.js +0 -91
- package/fesm2015/ngx-speculoos.js.map +0 -1
package/lib/route.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { Type } from '@angular/core';
|
|
|
16
16
|
* `route.parent.snapshot` or `route.snapshot.parent`.
|
|
17
17
|
*
|
|
18
18
|
* @returns a partially populated, fake ActivatedRoute, depending on what you passed in
|
|
19
|
+
* @deprecated favor stubRoute, which creates an easier to use and more logical stub
|
|
19
20
|
*/
|
|
20
21
|
export declare function fakeRoute(options: {
|
|
21
22
|
url?: Observable<UrlSegment[]>;
|
|
@@ -53,6 +54,7 @@ export declare function fakeRoute(options: {
|
|
|
53
54
|
* The same goes for queryParams and queryParamMap.
|
|
54
55
|
*
|
|
55
56
|
* @returns a partially populated, fake ActivatedRoute, depending on what you passed in
|
|
57
|
+
* @deprecated favor stubRoute, which creates an easier to use and more logical stub for both the route and its snapshot
|
|
56
58
|
*/
|
|
57
59
|
export declare function fakeSnapshot(options: {
|
|
58
60
|
url?: UrlSegment[];
|
|
@@ -81,3 +83,150 @@ export declare function fakeSnapshot(options: {
|
|
|
81
83
|
/** The path from the root of the router state tree to this route */
|
|
82
84
|
pathFromRoot?: ActivatedRouteSnapshot[];
|
|
83
85
|
}): ActivatedRouteSnapshot;
|
|
86
|
+
/**
|
|
87
|
+
* The options that are passed when creating an ActivatedRouteStub.
|
|
88
|
+
*/
|
|
89
|
+
export interface ActivatedRouteStubOptions {
|
|
90
|
+
/**
|
|
91
|
+
* The initial values of the parameters of the route
|
|
92
|
+
*/
|
|
93
|
+
params?: Params;
|
|
94
|
+
/**
|
|
95
|
+
* The initial values of the query parameters of the route
|
|
96
|
+
*/
|
|
97
|
+
queryParams?: Params;
|
|
98
|
+
/**
|
|
99
|
+
* The initial values of the data of the route
|
|
100
|
+
*/
|
|
101
|
+
data?: Data;
|
|
102
|
+
/**
|
|
103
|
+
* The initial fragment of the route
|
|
104
|
+
*/
|
|
105
|
+
fragment?: string | null;
|
|
106
|
+
/**
|
|
107
|
+
* The initial url of the route
|
|
108
|
+
*/
|
|
109
|
+
url?: UrlSegment[];
|
|
110
|
+
/**
|
|
111
|
+
* The parent of the route
|
|
112
|
+
*/
|
|
113
|
+
parent?: ActivatedRouteStub | null;
|
|
114
|
+
/**
|
|
115
|
+
* The first child of the route
|
|
116
|
+
*/
|
|
117
|
+
firstChild?: ActivatedRouteStub | null;
|
|
118
|
+
/**
|
|
119
|
+
* The children of the route
|
|
120
|
+
*/
|
|
121
|
+
children?: ActivatedRouteStub[] | null;
|
|
122
|
+
/**
|
|
123
|
+
* The configuration of the route
|
|
124
|
+
*/
|
|
125
|
+
routeConfig?: Route | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A stub for ActivatedRoute. It behaves almost the same way as the actual ActivatedRoute, exposing a snapshot
|
|
129
|
+
* and observables for the params, query params etc., which are kept in sync.
|
|
130
|
+
*
|
|
131
|
+
* In addition, this stub allows simulating a navigation by changing the params, the query params, the fragment, etc.
|
|
132
|
+
* When that happens, the snapshot is modified, then the relevant observables emit the new values.
|
|
133
|
+
*
|
|
134
|
+
* There are some things that don't really work the same way as the real ActivatedRoute though:
|
|
135
|
+
* - the handling of the firstChild and of the children is entirely under the tester's responsibility. Setting the parent
|
|
136
|
+
* of a route stub does not add this route to the children of its parent, for example.
|
|
137
|
+
* - when changing the params, query params, fragment, etc., their associated observable emits unconditionally, instead of
|
|
138
|
+
* first checking if the value is actually different from before. It's thus the responsibility of the tester to not
|
|
139
|
+
* change the values if they're the same as before.
|
|
140
|
+
*/
|
|
141
|
+
export declare class ActivatedRouteStub extends ActivatedRoute {
|
|
142
|
+
private _firstChild;
|
|
143
|
+
private _children;
|
|
144
|
+
private readonly paramsSubject;
|
|
145
|
+
private readonly queryParamsSubject;
|
|
146
|
+
private readonly dataSubject;
|
|
147
|
+
private readonly fragmentSubject;
|
|
148
|
+
private readonly urlSubject;
|
|
149
|
+
private _parent;
|
|
150
|
+
private _root;
|
|
151
|
+
private _pathFromRoot;
|
|
152
|
+
/**
|
|
153
|
+
* Constructs a new instance, based on the given options.
|
|
154
|
+
* If an option is not provided (or if no option is provided at all), then the route has a default value for this option
|
|
155
|
+
* (empty parameters for example, null fragment, etc.)
|
|
156
|
+
* If no parent is passed, then this route has no parent and is thus set as the root. Otherwise, the root and the path
|
|
157
|
+
* from root are created based on the root and path from root of the given parent route.
|
|
158
|
+
*/
|
|
159
|
+
constructor(options?: ActivatedRouteStubOptions);
|
|
160
|
+
get root(): ActivatedRouteStub;
|
|
161
|
+
get parent(): ActivatedRouteStub | null;
|
|
162
|
+
get pathFromRoot(): Array<ActivatedRouteStub>;
|
|
163
|
+
get firstChild(): ActivatedRouteStub | null;
|
|
164
|
+
get children(): Array<ActivatedRouteStub>;
|
|
165
|
+
get routeConfig(): Route | null;
|
|
166
|
+
/**
|
|
167
|
+
* Triggers a navigation with the given new parameters. All the other parts (query params etc.) stay as the are.
|
|
168
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change the parameters.
|
|
169
|
+
*/
|
|
170
|
+
setParams(params: Params): void;
|
|
171
|
+
/**
|
|
172
|
+
* Triggers a navigation with the given new parameter. The other parameters, as well as all the other parts (query params etc.)
|
|
173
|
+
* stay as the are.
|
|
174
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change one parameter.
|
|
175
|
+
*/
|
|
176
|
+
setParam(name: string, value: string): void;
|
|
177
|
+
/**
|
|
178
|
+
* Triggers a navigation with the given new query parameters. All the other parts (params etc.) stay as the are.
|
|
179
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change the query parameters.
|
|
180
|
+
*/
|
|
181
|
+
setQueryParams(queryParams: Params): void;
|
|
182
|
+
/**
|
|
183
|
+
* Triggers a navigation with the given new parameter. The other query parameters, as well as all the other parts (params etc.)
|
|
184
|
+
* stay as the are.
|
|
185
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change one query parameter.
|
|
186
|
+
*/
|
|
187
|
+
setQueryParam(name: string, value: string): void;
|
|
188
|
+
/**
|
|
189
|
+
* Triggers a navigation with the given new data. The other parameters, as well as all the other parts (params etc.)
|
|
190
|
+
* stay as the are.
|
|
191
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change the data.
|
|
192
|
+
*/
|
|
193
|
+
setData(data: Data): void;
|
|
194
|
+
/**
|
|
195
|
+
* Triggers a navigation with the given new data item. The other data, as well as all the other parts (params etc.)
|
|
196
|
+
* stay as the are.
|
|
197
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change one data item.
|
|
198
|
+
*/
|
|
199
|
+
setDataItem(name: string, value: unknown): void;
|
|
200
|
+
/**
|
|
201
|
+
* Triggers a navigation with the given new fragment. The other parts (params etc.) stay as the are.
|
|
202
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change the fragment.
|
|
203
|
+
*/
|
|
204
|
+
setFragment(fragment: string | null): void;
|
|
205
|
+
/**
|
|
206
|
+
* Triggers a navigation with the given new url. The other parts (params etc.) stay as the are.
|
|
207
|
+
* This is a shortcut to `triggerNavigation` that can be used to only change the url.
|
|
208
|
+
*/
|
|
209
|
+
setUrl(url: Array<UrlSegment>): void;
|
|
210
|
+
/**
|
|
211
|
+
* Triggers a navigation based on the given options. If an option is undefined or null, it's ignored. Except for fragment, which is only
|
|
212
|
+
* ignored if it's undefined, because null is a valid value for a fragment.
|
|
213
|
+
*
|
|
214
|
+
* The non-ignored values are used to change the snapshot of the route. Once the snapshot has been modified,
|
|
215
|
+
* the observables corresponding to the updated parts emit the new value.
|
|
216
|
+
*
|
|
217
|
+
* So, setting params and query params will make the params and queryParams observables emit, but not the fragment, data and
|
|
218
|
+
* url observables for example. This is consistent to how the router behaves.
|
|
219
|
+
*/
|
|
220
|
+
triggerNavigation(options: {
|
|
221
|
+
params?: Params;
|
|
222
|
+
queryParams?: Params;
|
|
223
|
+
fragment?: string | null;
|
|
224
|
+
data?: Data | null;
|
|
225
|
+
url?: Array<UrlSegment> | null;
|
|
226
|
+
}): void;
|
|
227
|
+
toString(): string;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Creates a new ActivatedRouteStub, by calling its constructor.
|
|
231
|
+
*/
|
|
232
|
+
export declare function stubRoute(options?: ActivatedRouteStubOptions): ActivatedRouteStub;
|
|
@@ -4,7 +4,7 @@ import { TestElement } from './test-element';
|
|
|
4
4
|
import { TestTextArea } from './test-textarea';
|
|
5
5
|
import { TestInput } from './test-input';
|
|
6
6
|
import { ComponentTester } from './component-tester';
|
|
7
|
-
import { DebugElement } from '@angular/core';
|
|
7
|
+
import { DebugElement, Type } from '@angular/core';
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
@@ -14,48 +14,48 @@ export declare class TestElementQuerier {
|
|
|
14
14
|
constructor(tester: ComponentTester<unknown>, root: DebugElement);
|
|
15
15
|
static wrap(childDebugElement: DebugElement, tester: ComponentTester<unknown>): TestElement;
|
|
16
16
|
/**
|
|
17
|
-
* Gets the first element matching the given
|
|
17
|
+
* Gets the first element matching the given selector and wraps it into a TestElement. The actual type
|
|
18
18
|
* of the returned value is the TestElement subclass matching the type of the found element. So, if the
|
|
19
19
|
* matched element is an input for example, the method will return a TestInput. You can thus use
|
|
20
20
|
* `tester.element('#some-input') as TestInput`.
|
|
21
|
-
* @param selector a CSS selector
|
|
21
|
+
* @param selector a CSS or directive selector
|
|
22
22
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
23
23
|
*/
|
|
24
|
-
element(selector: string): TestElement | null;
|
|
24
|
+
element(selector: string | Type<any>): TestElement | null;
|
|
25
25
|
/**
|
|
26
|
-
* Gets all the elements matching the given
|
|
26
|
+
* Gets all the elements matching the given selector and wraps them into a TestElement. The actual type
|
|
27
27
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
28
28
|
* matched elements are inputs for example, the method will return an array of TestInput. You can thus use
|
|
29
29
|
* `tester.elements('input') as Array<TestInput>`.
|
|
30
|
-
* @param selector a CSS selector
|
|
30
|
+
* @param selector a CSS or directive selector
|
|
31
31
|
* @returns the array of matched elements, empty if no element was matched
|
|
32
32
|
*/
|
|
33
|
-
elements(selector: string): Array<TestElement>;
|
|
33
|
+
elements(selector: string | Type<any>): Array<TestElement>;
|
|
34
34
|
/**
|
|
35
35
|
* Gets the first input matched by the given selector. Throws an Error if the matched element isn't actually an input.
|
|
36
|
-
* @param selector a CSS selector
|
|
36
|
+
* @param selector a CSS or directive selector
|
|
37
37
|
* @returns the wrapped input, or null if no element was matched
|
|
38
38
|
*/
|
|
39
|
-
input(selector: string): TestInput | null;
|
|
39
|
+
input(selector: string | Type<any>): TestInput | null;
|
|
40
40
|
/**
|
|
41
41
|
* Gets the first select matched by the given selector. Throws an Error if the matched element isn't actually a select.
|
|
42
|
-
* @param selector a CSS selector
|
|
42
|
+
* @param selector a CSS or directive selector
|
|
43
43
|
* @returns the wrapped select, or null if no element was matched
|
|
44
44
|
*/
|
|
45
|
-
select(selector: string): TestSelect | null;
|
|
45
|
+
select(selector: string | Type<any>): TestSelect | null;
|
|
46
46
|
/**
|
|
47
47
|
* Gets the first textarea matched by the given selector
|
|
48
|
-
* @param selector a CSS selector
|
|
48
|
+
* @param selector a CSS or directive selector
|
|
49
49
|
* @returns the wrapped textarea, or null if no element was matched. Throws an Error if the matched element isn't actually a textarea.
|
|
50
50
|
* @throws {Error} if the matched element isn't actually a textarea
|
|
51
51
|
*/
|
|
52
|
-
textarea(selector: string): TestTextArea | null;
|
|
52
|
+
textarea(selector: string | Type<any>): TestTextArea | null;
|
|
53
53
|
/**
|
|
54
54
|
* Gets the first button matched by the given selector. Throws an Error if the matched element isn't actually a button.
|
|
55
|
-
* @param selector a CSS selector
|
|
55
|
+
* @param selector a CSS or directive selector
|
|
56
56
|
* @returns the wrapped button, or null if no element was matched
|
|
57
57
|
*/
|
|
58
|
-
button(selector: string): TestButton | null;
|
|
58
|
+
button(selector: string | Type<any>): TestButton | null;
|
|
59
59
|
private query;
|
|
60
60
|
private queryAll;
|
|
61
61
|
}
|
package/lib/test-element.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { TestButton } from './test-button';
|
|
|
3
3
|
import { TestSelect } from './test-select';
|
|
4
4
|
import { TestTextArea } from './test-textarea';
|
|
5
5
|
import { TestInput } from './test-input';
|
|
6
|
-
import { DebugElement } from '@angular/core';
|
|
6
|
+
import { DebugElement, ProviderToken, Type } from '@angular/core';
|
|
7
7
|
import { TestHtmlElement } from './test-html-element';
|
|
8
8
|
/**
|
|
9
9
|
* A wrapped DOM element, providing additional methods and attributes helping with writing tests
|
|
@@ -74,82 +74,82 @@ export declare class TestElement<E extends Element = Element> {
|
|
|
74
74
|
* <code>
|
|
75
75
|
* const testElement: TestElement | null = tester.element('.selector');
|
|
76
76
|
* </code>
|
|
77
|
-
* @param selector a CSS selector
|
|
77
|
+
* @param selector a CSS or directive selector
|
|
78
78
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
79
79
|
*/
|
|
80
|
-
element(selector: string): TestElement | null;
|
|
80
|
+
element(selector: string | Type<any>): TestElement | null;
|
|
81
81
|
/**
|
|
82
|
-
* Gets the first element matching the given
|
|
82
|
+
* Gets the first element matching the given selector and wraps it into a TestElement. The actual type
|
|
83
83
|
* of the returned value is the TestElement subclass matching the type of the found element. So, if the
|
|
84
84
|
* matched element is an input for example, the method will return a TestInput.
|
|
85
85
|
* <p>Usage:</p>
|
|
86
86
|
* <code>
|
|
87
87
|
* const testElement: TestInput | null = tester.element<HTMLInputElement>('.selector');
|
|
88
88
|
* </code>
|
|
89
|
-
* @param selector a CSS selector
|
|
89
|
+
* @param selector a CSS or directive selector
|
|
90
90
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
91
91
|
*/
|
|
92
|
-
element<T extends HTMLInputElement>(selector: string): TestInput | null;
|
|
92
|
+
element<T extends HTMLInputElement>(selector: string | Type<any>): TestInput | null;
|
|
93
93
|
/**
|
|
94
|
-
* Gets the first element matching the given
|
|
94
|
+
* Gets the first element matching the given selector and wraps it into a TestElement. The actual type
|
|
95
95
|
* of the returned value is the TestElement subclass matching the type of the found element. So, if the
|
|
96
96
|
* matched element is an input for example, the method will return a TestInput.
|
|
97
97
|
* <p>Usage:</p>
|
|
98
98
|
* <code>
|
|
99
99
|
* const testElement: TestTextArea | null = tester.element<HTMLTextAreaElement>('.selector');
|
|
100
100
|
* </code>
|
|
101
|
-
* @param selector a CSS selector
|
|
101
|
+
* @param selector a CSS or directive selector
|
|
102
102
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
103
103
|
*/
|
|
104
|
-
element<T extends HTMLTextAreaElement>(selector: string): TestTextArea | null;
|
|
104
|
+
element<T extends HTMLTextAreaElement>(selector: string | Type<any>): TestTextArea | null;
|
|
105
105
|
/**
|
|
106
|
-
* Gets the first element matching the given
|
|
106
|
+
* Gets the first element matching the given selector and wraps it into a TestElement. The actual type
|
|
107
107
|
* of the returned value is the TestElement subclass matching the type of the found element. So, if the
|
|
108
108
|
* matched element is an input for example, the method will return a TestInput.
|
|
109
109
|
* <p>Usage:</p>
|
|
110
110
|
* <code>
|
|
111
111
|
* const testElement: TestSelect | null = tester.element<HTMLSelectElement>('.selector');
|
|
112
112
|
* </code>
|
|
113
|
-
* @param selector a CSS selector
|
|
113
|
+
* @param selector a CSS or directive selector
|
|
114
114
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
115
115
|
*/
|
|
116
|
-
element<T extends HTMLSelectElement>(selector: string): TestSelect | null;
|
|
116
|
+
element<T extends HTMLSelectElement>(selector: string | Type<any>): TestSelect | null;
|
|
117
117
|
/**
|
|
118
|
-
* Gets the first element matching the given
|
|
118
|
+
* Gets the first element matching the given selector and wraps it into a TestElement. The actual type
|
|
119
119
|
* of the returned value is the TestElement subclass matching the type of the found element. So, if the
|
|
120
120
|
* matched element is an input for example, the method will return a TestInput.
|
|
121
121
|
* <p>Usage:</p>
|
|
122
122
|
* <code>
|
|
123
123
|
* const testElement: TestButton | null = tester.element<HTMLButtonElement>('.selector');
|
|
124
124
|
* </code>
|
|
125
|
-
* @param selector a CSS selector
|
|
125
|
+
* @param selector a CSS or directive selector
|
|
126
126
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
127
127
|
*/
|
|
128
|
-
element<T extends HTMLButtonElement>(selector: string): TestButton | null;
|
|
128
|
+
element<T extends HTMLButtonElement>(selector: string | Type<any>): TestButton | null;
|
|
129
129
|
/**
|
|
130
|
-
* Gets the first element matching the given
|
|
130
|
+
* Gets the first element matching the given selector and wraps it into a TestElement. The actual type
|
|
131
131
|
* of the returned value is the TestElement subclass matching the type of the found element. So, if the
|
|
132
132
|
* matched element is an input for example, the method will return a TestInput.
|
|
133
133
|
* <p>Usage:</p>
|
|
134
134
|
* <code>
|
|
135
135
|
* const testElement: TestHtmlElement<HTMLDivElement> | null = tester.element<HTMLDivElement>('.selector');
|
|
136
136
|
* </code>
|
|
137
|
-
* @param selector a CSS selector
|
|
137
|
+
* @param selector a CSS or directive selector
|
|
138
138
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
139
139
|
*/
|
|
140
|
-
element<T extends HTMLElement>(selector: string): TestHtmlElement<T> | null;
|
|
140
|
+
element<T extends HTMLElement>(selector: string | Type<any>): TestHtmlElement<T> | null;
|
|
141
141
|
/**
|
|
142
|
-
* Gets the first element matching the given
|
|
142
|
+
* Gets the first element matching the given selector and wraps it into a TestElement. The actual type
|
|
143
143
|
* of the returned value is the TestElement subclass matching the type of the found element. So, if the
|
|
144
144
|
* matched element is an input for example, the method will return a TestInput.
|
|
145
145
|
* <p>Usage:</p>
|
|
146
146
|
* <code>
|
|
147
147
|
* const testElement: TestElement<SVGLineElement> | null = tester.element<SVGLineElement>('.selector');
|
|
148
148
|
* </code>
|
|
149
|
-
* @param selector a CSS selector
|
|
149
|
+
* @param selector a CSS or directive selector
|
|
150
150
|
* @returns the wrapped element, or null if no element matches the selector.
|
|
151
151
|
*/
|
|
152
|
-
element<T extends Element>(selector: string): TestElement<T> | null;
|
|
152
|
+
element<T extends Element>(selector: string | Type<any>): TestElement<T> | null;
|
|
153
153
|
/**
|
|
154
154
|
* Gets all the elements matching the given CSS selector and wraps them into a TestElement. The actual type
|
|
155
155
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
@@ -175,41 +175,41 @@ export declare class TestElement<E extends Element = Element> {
|
|
|
175
175
|
*/
|
|
176
176
|
elements<K extends keyof SVGElementTagNameMap>(selector: K): Array<TestElement<SVGElementTagNameMap[K]>>;
|
|
177
177
|
/**
|
|
178
|
-
* Gets all the elements matching the given
|
|
178
|
+
* Gets all the elements matching the given selector and wraps them into a TestElement. The actual type
|
|
179
179
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
180
180
|
* matched elements are inputs for example, the method will return an array of TestInput.
|
|
181
181
|
* <p>Usage:</p>
|
|
182
182
|
* <code>
|
|
183
183
|
* const testElements: Array<TestElement> = tester.elements('.selector');
|
|
184
184
|
* </code>
|
|
185
|
-
* @param selector a CSS selector
|
|
185
|
+
* @param selector a CSS or directive selector
|
|
186
186
|
* @returns the array of matched elements, empty if no element was matched
|
|
187
187
|
*/
|
|
188
|
-
elements(selector: string): Array<TestElement>;
|
|
188
|
+
elements(selector: string | Type<any>): Array<TestElement>;
|
|
189
189
|
/**
|
|
190
|
-
* Gets all the elements matching the given
|
|
190
|
+
* Gets all the elements matching the given selector and wraps them into a TestElement. The actual type
|
|
191
191
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
192
192
|
* matched elements are inputs for example, the method will return an array of TestInput.
|
|
193
193
|
* <p>Usage:</p>
|
|
194
194
|
* <code>
|
|
195
195
|
* const testElements: Array<TestInput> = tester.elements<HTMLInputElement>('.selector');
|
|
196
196
|
* </code>
|
|
197
|
-
* @param selector a CSS selector
|
|
197
|
+
* @param selector a CSS or directive selector
|
|
198
198
|
* @returns the array of matched elements, empty if no element was matched
|
|
199
199
|
*/
|
|
200
|
-
elements<T extends HTMLInputElement>(selector: string): Array<TestInput>;
|
|
200
|
+
elements<T extends HTMLInputElement>(selector: string | Type<any>): Array<TestInput>;
|
|
201
201
|
/**
|
|
202
|
-
* Gets all the elements matching the given
|
|
202
|
+
* Gets all the elements matching the given selector and wraps them into a TestElement. The actual type
|
|
203
203
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
204
204
|
* matched elements are inputs for example, the method will return an array of TestInput.
|
|
205
205
|
* <p>Usage:</p>
|
|
206
206
|
* <code>
|
|
207
207
|
* const testElements: Array<TestTextArea> = tester.elements<HTMLTextAreaElement>('.selector');
|
|
208
208
|
* </code>
|
|
209
|
-
* @param selector a CSS selector
|
|
209
|
+
* @param selector a CSS or directive selector
|
|
210
210
|
* @returns the array of matched elements, empty if no element was matched
|
|
211
211
|
*/
|
|
212
|
-
elements<T extends HTMLTextAreaElement>(selector: string): Array<TestTextArea>;
|
|
212
|
+
elements<T extends HTMLTextAreaElement>(selector: string | Type<any>): Array<TestTextArea>;
|
|
213
213
|
/**
|
|
214
214
|
* Gets all the elements matching the given CSS selector and wraps them into a TestElement. The actual type
|
|
215
215
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
@@ -218,69 +218,107 @@ export declare class TestElement<E extends Element = Element> {
|
|
|
218
218
|
* <code>
|
|
219
219
|
* const testElements: Array<TestButton> = tester.elements<HTMLButtonElement>('.selector');
|
|
220
220
|
* </code>
|
|
221
|
-
* @param selector a CSS selector
|
|
221
|
+
* @param selector a CSS or directive selector
|
|
222
222
|
* @returns the array of matched elements, empty if no element was matched
|
|
223
223
|
*/
|
|
224
|
-
elements<T extends HTMLButtonElement>(selector: string): Array<TestButton>;
|
|
224
|
+
elements<T extends HTMLButtonElement>(selector: string | Type<any>): Array<TestButton>;
|
|
225
225
|
/**
|
|
226
|
-
* Gets all the elements matching the given
|
|
226
|
+
* Gets all the elements matching the given selector and wraps them into a TestElement. The actual type
|
|
227
227
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
228
228
|
* matched elements are inputs for example, the method will return an array of TestInput.
|
|
229
229
|
* <p>Usage:</p>
|
|
230
230
|
* <code>
|
|
231
231
|
* const testElements: Array<TestSelect> = tester.elements<HTMLSelectElement>('.selector');
|
|
232
232
|
* </code>
|
|
233
|
-
* @param selector a CSS selector
|
|
233
|
+
* @param selector a CSS or directive selector
|
|
234
234
|
* @returns the array of matched elements, empty if no element was matched
|
|
235
235
|
*/
|
|
236
|
-
elements<T extends HTMLSelectElement>(selector: string): Array<TestSelect>;
|
|
236
|
+
elements<T extends HTMLSelectElement>(selector: string | Type<any>): Array<TestSelect>;
|
|
237
237
|
/**
|
|
238
|
-
* Gets all the elements matching the given
|
|
238
|
+
* Gets all the elements matching the given selector and wraps them into a TestElement. The actual type
|
|
239
239
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
240
240
|
* matched elements are inputs for example, the method will return an array of TestInput.
|
|
241
241
|
* <p>Usage:</p>
|
|
242
242
|
* <code>
|
|
243
243
|
* const testElements: Array<TestHtmlElement<HTMLDivElement>> = tester.elements<HTMLDivElement>('.selector');
|
|
244
244
|
* </code>
|
|
245
|
-
* @param selector a CSS selector
|
|
245
|
+
* @param selector a CSS or directive selector
|
|
246
246
|
* @returns the array of matched elements, empty if no element was matched
|
|
247
247
|
*/
|
|
248
|
-
elements<T extends HTMLElement>(selector: string): Array<TestHtmlElement<T>>;
|
|
248
|
+
elements<T extends HTMLElement>(selector: string | Type<any>): Array<TestHtmlElement<T>>;
|
|
249
249
|
/**
|
|
250
|
-
* Gets all the elements matching the given
|
|
250
|
+
* Gets all the elements matching the given selector and wraps them into a TestElement. The actual type
|
|
251
251
|
* of the returned elements is the TestElement subclass matching the type of the found element. So, if the
|
|
252
252
|
* matched elements are inputs for example, the method will return an array of TestInput.
|
|
253
253
|
* <p>Usage:</p>
|
|
254
254
|
* <code>
|
|
255
255
|
* const testElements: Array<TestElement<SVGLineElement>> = tester.elements<SVGLineElement>('.selector');
|
|
256
256
|
* </code>
|
|
257
|
-
* @param selector a CSS selector
|
|
257
|
+
* @param selector a CSS or directive selector
|
|
258
258
|
* @returns the array of matched elements, empty if no element was matched
|
|
259
259
|
*/
|
|
260
|
-
elements<T extends Element>(selector: string): Array<TestElement<T>>;
|
|
260
|
+
elements<T extends Element>(selector: string | Type<any>): Array<TestElement<T>>;
|
|
261
261
|
/**
|
|
262
262
|
* Gets the first input matched by the given selector. Throws an Error if the matched element isn't actually an input.
|
|
263
|
-
* @param selector a CSS selector
|
|
263
|
+
* @param selector a CSS or directive selector
|
|
264
264
|
* @returns the wrapped input, or null if no element was matched
|
|
265
265
|
*/
|
|
266
|
-
input(selector: string): TestInput | null;
|
|
266
|
+
input(selector: string | Type<any>): TestInput | null;
|
|
267
267
|
/**
|
|
268
268
|
* Gets the first select matched by the given selector. Throws an Error if the matched element isn't actually a select.
|
|
269
|
-
* @param selector a CSS selector
|
|
269
|
+
* @param selector a CSS or directive selector
|
|
270
270
|
* @returns the wrapped select, or null if no element was matched
|
|
271
271
|
*/
|
|
272
|
-
select(selector: string): TestSelect | null;
|
|
272
|
+
select(selector: string | Type<any>): TestSelect | null;
|
|
273
273
|
/**
|
|
274
274
|
* Gets the first textarea matched by the given selector
|
|
275
|
-
* @param selector a CSS selector
|
|
275
|
+
* @param selector a CSS or directive selector
|
|
276
276
|
* @returns the wrapped textarea, or null if no element was matched. Throws an Error if the matched element isn't actually a textarea.
|
|
277
277
|
* @throws {Error} if the matched element isn't actually a textarea
|
|
278
278
|
*/
|
|
279
|
-
textarea(selector: string): TestTextArea | null;
|
|
279
|
+
textarea(selector: string | Type<any>): TestTextArea | null;
|
|
280
280
|
/**
|
|
281
281
|
* Gets the first button matched by the given selector. Throws an Error if the matched element isn't actually a button.
|
|
282
|
-
* @param selector a CSS selector
|
|
282
|
+
* @param selector a CSS or directive selector
|
|
283
283
|
* @returns the wrapped button, or null if no element was matched
|
|
284
284
|
*/
|
|
285
|
-
button(selector: string): TestButton | null;
|
|
285
|
+
button(selector: string | Type<any>): TestButton | null;
|
|
286
|
+
/**
|
|
287
|
+
* Gets the first directive matching the given component directive selector and returns its component instance
|
|
288
|
+
* @param selector the selector of a component directive
|
|
289
|
+
*/
|
|
290
|
+
component<R>(selector: Type<R>): R;
|
|
291
|
+
/**
|
|
292
|
+
* Gets the directives matching the given component directive selector and returns their component instance
|
|
293
|
+
* @param selector the selector of a component directive
|
|
294
|
+
*/
|
|
295
|
+
components<R>(selector: Type<R>): Array<R>;
|
|
296
|
+
/**
|
|
297
|
+
* Gets the first element matching the given selector, then gets the given token from its injector, or null if there is no such token
|
|
298
|
+
* @param selector a CSS or directive selector
|
|
299
|
+
* @param token the token to get from the matched element injector
|
|
300
|
+
*/
|
|
301
|
+
token<R>(selector: string | Type<any>, token: ProviderToken<R>): R | null;
|
|
302
|
+
/**
|
|
303
|
+
* Gets the elements matching the given selector, then gets their given token from their injector, or null if there is no such token
|
|
304
|
+
* @param selector a CSS or directive selector
|
|
305
|
+
* @param token the token to get from the matched element injector
|
|
306
|
+
*/
|
|
307
|
+
tokens<R>(selector: string | Type<any>, token: ProviderToken<R>): Array<R | null>;
|
|
308
|
+
/**
|
|
309
|
+
* Gets the element matching the given selector, and if found, creates and returns a custom TestElement of the provided
|
|
310
|
+
* type. This is useful to create custom higher-level abstractions similar to TestInput, TestSelect, etc. for
|
|
311
|
+
* custom elements or components.
|
|
312
|
+
* @param selector a CSS or directive selector
|
|
313
|
+
* @param customTestElementType the type of the TestElement subclass that will wrap the found element
|
|
314
|
+
*/
|
|
315
|
+
custom<E extends TestElement>(selector: string | Type<any>, customTestElementType: Type<E>): E | null;
|
|
316
|
+
/**
|
|
317
|
+
* Gets the elements matching the given selector, and creates and returns custom TestElements of the provided
|
|
318
|
+
* type. This is useful to create custom higher-level abstractions similar to TestInput, TestSelect, etc. for
|
|
319
|
+
* custom elements or components.
|
|
320
|
+
* @param selector a CSS or directive selector
|
|
321
|
+
* @param customTestElementType the type of the TestElement subclass that will wrap the found elements
|
|
322
|
+
*/
|
|
323
|
+
customs<E extends TestElement>(selector: string | Type<any>, customTestElementType: Type<E>): Array<E>;
|
|
286
324
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-speculoos",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Helps writing Angular unit tests",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@angular/core": "^
|
|
7
|
-
"@angular/platform-browser": "^
|
|
8
|
-
"@angular/router": "^
|
|
9
|
-
"rxjs": "^
|
|
6
|
+
"@angular/core": "^13.0.0",
|
|
7
|
+
"@angular/platform-browser": "^13.0.0",
|
|
8
|
+
"@angular/router": "^13.0.0",
|
|
9
|
+
"rxjs": "^7.4.0"
|
|
10
10
|
},
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"repository": {
|
|
@@ -25,13 +25,26 @@
|
|
|
25
25
|
"save": "devDependencies"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"tslib": "2.
|
|
28
|
+
"tslib": "2.3.1"
|
|
29
29
|
},
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"fesm2015": "fesm2015/ngx-speculoos.
|
|
30
|
+
"module": "fesm2015/ngx-speculoos.mjs",
|
|
31
|
+
"es2020": "fesm2020/ngx-speculoos.mjs",
|
|
32
|
+
"esm2020": "esm2020/ngx-speculoos.mjs",
|
|
33
|
+
"fesm2020": "fesm2020/ngx-speculoos.mjs",
|
|
34
|
+
"fesm2015": "fesm2015/ngx-speculoos.mjs",
|
|
35
35
|
"typings": "ngx-speculoos.d.ts",
|
|
36
|
+
"exports": {
|
|
37
|
+
"./package.json": {
|
|
38
|
+
"default": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
".": {
|
|
41
|
+
"types": "./ngx-speculoos.d.ts",
|
|
42
|
+
"esm2020": "./esm2020/ngx-speculoos.mjs",
|
|
43
|
+
"es2020": "./fesm2020/ngx-speculoos.mjs",
|
|
44
|
+
"es2015": "./fesm2015/ngx-speculoos.mjs",
|
|
45
|
+
"node": "./fesm2015/ngx-speculoos.mjs",
|
|
46
|
+
"default": "./fesm2020/ngx-speculoos.mjs"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
36
49
|
"sideEffects": false
|
|
37
50
|
}
|
package/public_api.d.ts
CHANGED