ng-mocks 13.0.4 → 13.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.
@@ -1,3 +1,3 @@
1
1
  import { AnyType } from './core.types';
2
2
  import { ngMocksMockConfig } from './mock';
3
- export default function (mock: AnyType<any>, source: AnyType<any>, config?: ngMocksMockConfig): void;
3
+ export default function (mock: AnyType<any>, source: AnyType<any>, configInput?: ngMocksMockConfig): void;
@@ -32,4 +32,4 @@ export declare function getMockedNgDefOf<T>(declaration: AnyType<T>, type: 'p'):
32
32
  *
33
33
  * @see https://ng-mocks.sudo.eu/api/helpers/getMockedNgDefOf
34
34
  */
35
- export declare function getMockedNgDefOf(declaration: AnyType<any>): Type<any>;
35
+ export declare function getMockedNgDefOf<T>(declaration: AnyType<T>): Type<T>;
@@ -1,4 +1,5 @@
1
1
  import { InjectionToken } from '@angular/core';
2
+ import { IMockBuilderConfig } from '../mock-builder/types';
2
3
  import { AnyType } from './core.types';
3
4
  interface NgMocksUniverse {
4
5
  builtDeclarations: Map<any, any>;
@@ -9,6 +10,7 @@ interface NgMocksUniverse {
9
10
  configInstance: Map<any, any>;
10
11
  flags: Set<string>;
11
12
  getBuildDeclaration: (def: any) => any | undefined;
13
+ getConfigMock: () => Map<any, IMockBuilderConfig>;
12
14
  getDefaults: () => Map<any, ['mock' | 'keep' | 'replace' | 'exclude', any?]>;
13
15
  getLocalMocks: () => Array<[any, any]>;
14
16
  getOverrides: () => Map<any, any>;
@@ -1,8 +1,8 @@
1
- import { NgModule } from '@angular/core';
1
+ import { TestModuleMetadata } from '@angular/core/testing';
2
2
  import { MockBuilderPromise } from './mock-builder.promise';
3
3
  import { IMockBuilderResult } from './types';
4
4
  export declare class MockBuilderPerformance extends MockBuilderPromise {
5
- build(): NgModule;
5
+ build(): TestModuleMetadata;
6
6
  then<TResult1 = IMockBuilderResult>(fulfill?: ((value: IMockBuilderResult) => PromiseLike<TResult1>) | undefined | null, reject?: ((reason: any) => PromiseLike<never>) | undefined | null): Promise<TResult1>;
7
7
  private cloneConfig;
8
8
  private equalsTo;
@@ -1,5 +1,5 @@
1
- import { NgModule, Provider } from '@angular/core';
2
- import { TestBed } from '@angular/core/testing';
1
+ import { Provider } from '@angular/core';
2
+ import { TestBed, TestModuleMetadata } from '@angular/core/testing';
3
3
  import { Type } from '../common/core.types';
4
4
  import { MockBuilderStash } from './mock-builder-stash';
5
5
  import { BuilderData } from './promise/types';
@@ -20,7 +20,7 @@ export declare class MockBuilderPromise implements IMockBuilder {
20
20
  protected stash: MockBuilderStash;
21
21
  constructor();
22
22
  beforeCompileComponents(callback: (testBed: typeof TestBed) => void): this;
23
- build(): NgModule;
23
+ build(): TestModuleMetadata;
24
24
  catch(reject?: ((reason: any) => PromiseLike<never>) | undefined | null): Promise<IMockBuilderResult>;
25
25
  exclude(def: any): this;
26
26
  finally(callback?: (() => void) | null | undefined): Promise<IMockBuilderResult>;
@@ -1,5 +1,5 @@
1
- import { InjectionToken, NgModule, PipeTransform, Provider } from '@angular/core';
2
- import { TestBed } from '@angular/core/testing';
1
+ import { InjectionToken, PipeTransform, Provider } from '@angular/core';
2
+ import { TestBed, TestModuleMetadata } from '@angular/core/testing';
3
3
  import { AnyType } from '../common/core.types';
4
4
  export interface IMockBuilderResult {
5
5
  testBed: typeof TestBed;
@@ -52,7 +52,7 @@ export interface IMockBuilder extends Promise<IMockBuilderResult> {
52
52
  /**
53
53
  * @see https://ng-mocks.sudo.eu/api/MockBuilder#factory-function
54
54
  */
55
- build(): NgModule;
55
+ build(): TestModuleMetadata;
56
56
  /**
57
57
  * @see https://ng-mocks.sudo.eu/api/MockBuilder#exclude
58
58
  */
@@ -2,6 +2,7 @@ import { DebugNode, EventEmitter, InjectionToken, Injector, Provider, TemplateRe
2
2
  import { ComponentFixture, TestModuleMetadata } from '@angular/core/testing';
3
3
  import { AnyType, DebugNodeSelector, Type } from '../common/core.types';
4
4
  import { NgModuleWithProviders } from '../common/func.is-ng-module-def-with-providers';
5
+ import { IMockBuilderConfig } from '../mock-builder/types';
5
6
  import { MockedDebugElement, MockedDebugNode } from '../mock-render/types';
6
7
  import { CustomMockFunction, MockedFunction } from '../mock-service/types';
7
8
  import { FORMAT_SET, FORMAT_SINGLE } from './format/types';
@@ -34,22 +35,26 @@ export declare const ngMocks: {
34
35
  * @see https://ng-mocks.sudo.eu/api/ngMocks/crawl
35
36
  */
36
37
  crawl(elSelector: DebugNodeSelector, callback: (node: MockedDebugNode | MockedDebugElement, parent?: MockedDebugNode | MockedDebugElement) => boolean | void, includeTextNodes?: boolean): void;
38
+ /**
39
+ * @see https://ng-mocks.sudo.eu/api/ngMocks/defaultConfig
40
+ */
41
+ defaultConfig<T>(token: string | InjectionToken<T> | AnyType<T>, config?: IMockBuilderConfig): void;
37
42
  /**
38
43
  * @see https://ng-mocks.sudo.eu/api/ngMocks/defaultMock
39
44
  */
40
- defaultMock<T>(token: InjectionToken<T>, handler?: (value: undefined | T, injector: Injector) => undefined | Partial<T>): void;
45
+ defaultMock<T>(token: InjectionToken<T>, handler?: (value: undefined | T, injector: Injector) => undefined | Partial<T>, config?: IMockBuilderConfig): void;
41
46
  /**
42
47
  * @see https://ng-mocks.sudo.eu/api/ngMocks/defaultMock
43
48
  */
44
- defaultMock<T = any>(token: string, handler?: (value: undefined | T, injector: Injector) => undefined | Partial<T>): void;
49
+ defaultMock<T = any>(token: string, handler?: (value: undefined | T, injector: Injector) => undefined | Partial<T>, config?: IMockBuilderConfig): void;
45
50
  /**
46
51
  * @see https://ng-mocks.sudo.eu/api/ngMocks/defaultMock
47
52
  */
48
- defaultMock<T>(def: AnyType<T>, handler?: (value: T, injector: Injector) => void | Partial<T>): void;
53
+ defaultMock<T>(def: AnyType<T>, handler?: (value: T, injector: Injector) => void | Partial<T>, config?: IMockBuilderConfig): void;
49
54
  /**
50
55
  * @see https://ng-mocks.sudo.eu/api/ngMocks/defaultMock
51
56
  */
52
- defaultMock<T = any>(defs: Array<AnyType<T> | InjectionToken<T>>, handler?: (value: undefined | T, injector: Injector) => undefined | Partial<T>): void;
57
+ defaultMock<T = any>(defs: Array<AnyType<T> | InjectionToken<T>>, handler?: (value: undefined | T, injector: Injector) => undefined | Partial<T>, config?: IMockBuilderConfig): void;
53
58
  /**
54
59
  * @see https://ng-mocks.sudo.eu/api/ngMocks/event
55
60
  */
@@ -0,0 +1,5 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ import { AnyType } from '../common/core.types';
3
+ import { IMockBuilderConfig } from '../mock-builder/types';
4
+ declare const _default: <T>(def: string | AnyType<T> | InjectionToken<T> | (string | AnyType<T> | InjectionToken<T>)[], config?: IMockBuilderConfig | undefined) => void;
5
+ export default _default;
@@ -8,19 +8,20 @@ declare const _default: {
8
8
  onTestBedFlushNeed?: 'throw' | 'warn' | 'i-know-but-disable' | null;
9
9
  }) => void;
10
10
  crawl: (sel: import("../..").DebugNodeSelector, callback: (node: import("@angular/core").DebugNode) => boolean | void, includeTextNode?: boolean) => void;
11
- defaultMock: <T>(def: string | import("../..").AnyType<T> | import("@angular/core").InjectionToken<T> | (string | import("../..").AnyType<T> | import("@angular/core").InjectionToken<T>)[], callback?: ((instance: T | undefined, injector: import("@angular/core").Injector) => void | Partial<T>) | undefined) => void;
11
+ defaultConfig: <T>(def: string | import("../..").AnyType<T> | import("@angular/core").InjectionToken<T> | (string | import("../..").AnyType<T> | import("@angular/core").InjectionToken<T>)[], config?: import("../..").IMockBuilderConfig | undefined) => void;
12
+ defaultMock: <T_1>(def: string | import("../..").AnyType<T_1> | import("@angular/core").InjectionToken<T_1> | (string | import("../..").AnyType<T_1> | import("@angular/core").InjectionToken<T_1>)[], callback?: ((instance: T_1 | undefined, injector: import("@angular/core").Injector) => void | Partial<T_1>) | undefined) => void;
12
13
  event: (event: string, init?: EventInit | undefined, overrides?: Partial<Event | UIEvent | KeyboardEvent | MouseEvent | TouchEvent> | undefined) => CustomEvent<any>;
13
14
  faster: () => void;
14
15
  find: (...args: any[]) => import("@angular/core").DebugElement;
15
16
  findAll: (...args: any[]) => import("@angular/core").DebugElement[];
16
17
  findInstance: (...args: any[]) => any;
17
- findInstances: <T_1>(...args: any[]) => T_1[];
18
+ findInstances: <T_2>(...args: any[]) => T_2[];
18
19
  findTemplateRef: (...args: any[]) => any;
19
20
  findTemplateRefs: (...args: any[]) => import("@angular/core").TemplateRef<any>[];
20
21
  flushTestBed: () => void;
21
22
  formatHtml: (html: any, outer?: boolean) => any;
22
23
  formatText: (html: any, outer?: boolean) => any;
23
- get: <T_2>(...args: any[]) => any;
24
+ get: <T_3>(...args: any[]) => any;
24
25
  globalExclude: (source: import("../..").AnyType<any> | import("@angular/core").InjectionToken<any>) => void;
25
26
  globalKeep: (source: import("../..").AnyType<any> | import("@angular/core").InjectionToken<any>) => void;
26
27
  globalMock: (source: import("../..").AnyType<any> | import("@angular/core").InjectionToken<any>) => void;
@@ -35,8 +36,8 @@ declare const _default: {
35
36
  reset: () => void;
36
37
  reveal: (...args: any[]) => any;
37
38
  revealAll: (...args: any[]) => any[];
38
- stub: <T_3 = import("../..").MockedFunction>(instance: any, override: any, style?: "get" | "set" | undefined) => T_3;
39
- stubMember: <T_4 extends object>(instance: T_4, key: any, value: any, encapsulation?: "get" | "set" | undefined) => any;
39
+ stub: <T_4 = import("../..").MockedFunction>(instance: any, override: any, style?: "get" | "set" | undefined) => T_4;
40
+ stubMember: <T_5 extends object>(instance: T_5, key: any, value: any, encapsulation?: "get" | "set" | undefined) => any;
40
41
  throwOnConsole: (...methods: (keyof Console)[]) => void;
41
42
  touch: (sel: import("../..").DebugNodeSelector | import("@angular/core").DebugElement) => void;
42
43
  trigger: (selector: import("../..").DebugNodeSelector | import("@angular/core").DebugElement | HTMLElement, eventName: string | Event | UIEvent | KeyboardEvent | MouseEvent | TouchEvent, payload?: Partial<Event | UIEvent | KeyboardEvent | MouseEvent | TouchEvent> | undefined) => void;
@@ -10,6 +10,7 @@ export interface IMockRenderOptions {
10
10
  detectChanges?: boolean;
11
11
  providers?: Provider[];
12
12
  reset?: boolean;
13
+ viewProviders?: Provider[];
13
14
  }
14
15
  export interface IMockRenderFactoryOptions extends IMockRenderOptions {
15
16
  configureTestBed?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-mocks",
3
- "version": "13.0.4",
3
+ "version": "13.2.0",
4
4
  "description": "An Angular testing library for creating mock services, components, directives, pipes and modules in unit tests, which includes shallow rendering, precise stubs to dump child dependencies, supports Angular 5 6 7 8 9 10 11 12 13, jasmine and jest.",
5
5
  "keywords": [
6
6
  "angular",
@@ -81,9 +81,9 @@
81
81
  "test": "karma start"
82
82
  },
83
83
  "peerDependencies": {
84
- "@angular/common": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13",
85
- "@angular/core": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13",
86
- "@angular/forms": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13",
87
- "@angular/platform-browser": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13"
84
+ "@angular/common": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14",
85
+ "@angular/core": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14",
86
+ "@angular/forms": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14",
87
+ "@angular/platform-browser": "5.0.0-alpha - 5 || 6.0.0-alpha - 6 || 7.0.0-alpha - 7 || 8.0.0-alpha - 8 || 9.0.0-alpha - 9 || 10.0.0-alpha - 10 || 11.0.0-alpha - 11 || 12.0.0-alpha - 12 || 13.0.0-alpha - 13 || 14.0.0-alpha - 14"
88
88
  }
89
89
  }