-
-
Notifications
You must be signed in to change notification settings - Fork 71
/
func.is-mocked-ng-def-of.ts
62 lines (54 loc) · 1.98 KB
/
func.is-mocked-ng-def-of.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
import { PipeTransform } from '@angular/core';
import { MockedComponent } from '../mock-component/types';
import { MockedDirective } from '../mock-directive/types';
import { MockedModule } from '../mock-module/types';
import { MockedPipe } from '../mock-pipe/types';
import { Type } from './core.types';
import { isNgDef } from './func.is-ng-def';
/**
* Checks whether the declaration is a mock one and derives from the specified module.
*
* @see https://ng-mocks.sudo.eu/api/helpers/isMockedNgDefOf
*/
export function isMockedNgDefOf<T>(declaration: any, type: Type<T>, ngType: 'm'): declaration is Type<MockedModule<T>>;
/**
* Checks whether the declaration is a mock one and derives from the specified component.
*
* @see https://ng-mocks.sudo.eu/api/helpers/isMockedNgDefOf
*/
export function isMockedNgDefOf<T>(
declaration: any,
type: Type<T>,
ngType: 'c',
): declaration is Type<MockedComponent<T>>;
/**
* Checks whether the declaration is a mock one and derives from the specified directive.
*
* @see https://ng-mocks.sudo.eu/api/helpers/isMockedNgDefOf
*/
export function isMockedNgDefOf<T>(
declaration: any,
type: Type<T>,
ngType: 'd',
): declaration is Type<MockedDirective<T>>;
/**
* Checks whether the declaration is a mock one and derives from the specified pipe.
*
* @see https://ng-mocks.sudo.eu/api/helpers/isMockedNgDefOf
*/
export function isMockedNgDefOf<T extends PipeTransform>(
declaration: any,
type: Type<T>,
ngType: 'p',
): declaration is Type<MockedPipe<T>>;
/**
* Checks whether the declaration is a mock one and derives from the specified type.
*
* @see https://ng-mocks.sudo.eu/api/helpers/isMockedNgDefOf
*/
export function isMockedNgDefOf<T>(declaration: any, type: Type<T>): declaration is Type<T>;
export function isMockedNgDefOf<T>(declaration: any, type: Type<T>, ngType?: any): declaration is Type<T> {
return (
typeof declaration === 'function' && declaration.mockOf === type && (ngType ? isNgDef(declaration, ngType) : true)
);
}