ng-mocks 13.5.1 → 13.5.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.
@@ -18,6 +18,7 @@ import {
18
18
  MockBuilder,
19
19
  MockRender,
20
20
  NG_MOCKS_INTERCEPTORS,
21
+ ngMocks,
21
22
  } from 'ng-mocks';
22
23
 
23
24
  // An interceptor we want to test.
@@ -92,13 +93,13 @@ describe('TestHttpInterceptor', () => {
92
93
  });
93
94
 
94
95
  it('triggers interceptor', () => {
95
- const fixture = MockRender('');
96
- const client: HttpClient =
97
- fixture.debugElement.injector.get(HttpClient);
98
- const httpMock: HttpTestingController =
99
- fixture.debugElement.injector.get(HttpTestingController);
96
+ MockRender();
100
97
 
101
- // Let's do a simply request.
98
+ // Let's extract the service and http controller for testing.
99
+ const client = ngMocks.findInstance(HttpClient);
100
+ const httpMock = ngMocks.findInstance(HttpTestingController);
101
+
102
+ // Let's do a simple request.
102
103
  client.get('/target').subscribe();
103
104
 
104
105
  // Now we can assert that a header has been added to the request.
@@ -6,7 +6,7 @@ import {
6
6
  import { Injectable, NgModule } from '@angular/core';
7
7
  import { Observable } from 'rxjs';
8
8
 
9
- import { MockBuilder, MockRender } from 'ng-mocks';
9
+ import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
10
10
 
11
11
  // A service that does http requests.
12
12
  @Injectable()
@@ -39,12 +39,11 @@ describe('TestHttpRequest', () => {
39
39
  });
40
40
 
41
41
  it('sends a request', () => {
42
- const fixture = MockRender('');
42
+ MockRender();
43
+
43
44
  // Let's extract the service and http controller for testing.
44
- const service: TargetService =
45
- fixture.debugElement.injector.get(TargetService);
46
- const httpMock: HttpTestingController =
47
- fixture.debugElement.injector.get(HttpTestingController);
45
+ const service = ngMocks.findInstance(TargetService);
46
+ const httpMock = ngMocks.findInstance(HttpTestingController);
48
47
 
49
48
  // A simple subscription to check what the service returns.
50
49
  let actual: any;
@@ -100,7 +100,7 @@ describe('TestLifecycleHooks', () => {
100
100
  const service: TargetService =
101
101
  fixture.debugElement.injector.get(TargetService);
102
102
 
103
- // By default nothing should be initialized.
103
+ // By default, nothing should be initialized.
104
104
  expect(service.onChanges).toHaveBeenCalledTimes(0);
105
105
 
106
106
  // Now let's render the component.