-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
spectacular-pipe-harness.ts
56 lines (54 loc) · 1.63 KB
/
spectacular-pipe-harness.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
import type {
AbstractType,
InjectFlags,
InjectionToken,
Type,
} from '@angular/core';
import type { Observable } from 'rxjs';
/**
* A harness for testing an Angular pipe.
*
* Includes an API to write a value and read the rendered text.
*/
export abstract class SpectacularPipeHarness<TValue> {
/**
* Replace the pipe component template.
*
* NOTE! The `value` property is in context of the specified template.
*
* @param template The component template used to test the Angular pipe, for
* example `'{{ value | camelize }}'`.
*/
abstract set template(template: string);
/**
* Read the text rendered in the pipe component template.
*/
abstract get text(): string;
/**
* Update the value passed through the Angular pipe.
*
* @param value The new value.
*/
abstract set value(value: TValue | Observable<TValue> | null);
/**
* Resolve a dependency based on the specified dependency injection token.
*
* @param token The token representing the dependency, that is a class or an
* `InjectionToken`.
* @param notFoundValue The default value in case the specified dependency
* has not been provided. Optional. Default is `null`.
* @param flags Dependency injection options, for example
* `InjectFlags.Optional | InjectFlags.SkipSelf`. Optional. Default is
* `InjectFlags.Default`.
*/
abstract inject<T>(
token: Type<T> | InjectionToken<T> | AbstractType<T>,
notFoundValue?: T,
flags?: InjectFlags
): T;
abstract inject<T>(
token: Type<T> | InjectionToken<T> | AbstractType<T>,
notFoundValue: null,
flags?: InjectFlags
): T | null;
}