ng-mocks 14.3.0 → 14.3.2
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 +15 -20
- package/index.d.ts +13 -2
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -71,28 +71,21 @@ An example of a spec for a profile edit component.
|
|
|
71
71
|
// lastName, and a user can edit them.
|
|
72
72
|
// In the following test suite, we would like to
|
|
73
73
|
// cover behavior of the component.
|
|
74
|
-
describe('profile:
|
|
74
|
+
describe('profile:builder', () => {
|
|
75
75
|
// Helps to reset customizations after each test.
|
|
76
76
|
MockInstance.scope();
|
|
77
77
|
|
|
78
|
-
// Let's
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
MockComponent(AvatarComponent), // mock
|
|
90
|
-
ProfileComponent, // real
|
|
91
|
-
],
|
|
92
|
-
providers: [
|
|
93
|
-
MockProvider(AuthService), // mock
|
|
94
|
-
],
|
|
95
|
-
}).compileComponents();
|
|
78
|
+
// Let's configure TestBed via MockBuilder.
|
|
79
|
+
// The code below says to mock everything in
|
|
80
|
+
// ProfileModule except ProfileComponent and
|
|
81
|
+
// ReactiveFormsModule.
|
|
82
|
+
beforeEach(() => {
|
|
83
|
+
// The result of MockBuilder should be returned.
|
|
84
|
+
// https://ng-mocks.sudo.eu/api/MockBuilder
|
|
85
|
+
return MockBuilder(
|
|
86
|
+
ProfileComponent,
|
|
87
|
+
ProfileModule,
|
|
88
|
+
).keep(ReactiveFormsModule);
|
|
96
89
|
});
|
|
97
90
|
|
|
98
91
|
// A test to ensure that ProfileComponent
|
|
@@ -104,12 +97,14 @@ describe('profile:classic', () => {
|
|
|
104
97
|
// onPush change detection, and creates a
|
|
105
98
|
// wrapper component with a template like
|
|
106
99
|
// <app-root ...allInputs></profile>
|
|
100
|
+
// and renders it.
|
|
101
|
+
// It also respects all lifecycle hooks.
|
|
107
102
|
// https://ng-mocks.sudo.eu/api/MockRender
|
|
108
103
|
const fixture = MockRender(ProfileComponent);
|
|
109
104
|
|
|
110
105
|
expect(
|
|
111
106
|
fixture.point.componentInstance,
|
|
112
|
-
).toEqual(
|
|
107
|
+
).toEqual(assertion.any(ProfileComponent));
|
|
113
108
|
});
|
|
114
109
|
|
|
115
110
|
// A test to ensure that the component listens
|
package/index.d.ts
CHANGED
|
@@ -1078,9 +1078,20 @@ export declare function MockReset(): void;
|
|
|
1078
1078
|
*/
|
|
1079
1079
|
export interface NgModuleWithProviders<T = any> {
|
|
1080
1080
|
ngModule: Type<T>;
|
|
1081
|
-
providers?: Provider
|
|
1081
|
+
providers?: Array<Provider>;
|
|
1082
|
+
}
|
|
1083
|
+
/**
|
|
1084
|
+
* NgModuleWithProviders which supports A15
|
|
1085
|
+
*
|
|
1086
|
+
* @internal remove after removal of A5 support and switch to NgModuleWithProviders
|
|
1087
|
+
*/
|
|
1088
|
+
export interface NgModuleWithProvidersA15<T = any> {
|
|
1089
|
+
ngModule: Type<T>;
|
|
1090
|
+
providers?: Array<Provider | {
|
|
1091
|
+
ɵbrand: string;
|
|
1092
|
+
}>;
|
|
1082
1093
|
}
|
|
1083
|
-
export declare type MockBuilderParam = string | AnyDeclaration<any> | NgModuleWithProviders;
|
|
1094
|
+
export declare type MockBuilderParam = string | AnyDeclaration<any> | NgModuleWithProviders | NgModuleWithProvidersA15;
|
|
1084
1095
|
/**
|
|
1085
1096
|
* MockBuilder provides reach and simple interfaces of chain functions
|
|
1086
1097
|
* to build desired mock environment for tests.
|