From 00233171ccdff8663851b7c23fa33a3de1338baf Mon Sep 17 00:00:00 2001 From: satanTime Date: Sat, 22 Oct 2022 14:41:46 +0200 Subject: [PATCH] docs: sync with tests --- docs/articles/extra/extensive-example.md | 2 +- docs/articles/extra/mock-form-controls.md | 4 ++-- docs/articles/guides/http-interceptor.md | 1 + docs/articles/guides/http-request.md | 2 +- docs/articles/guides/provider.md | 4 ++-- examples/MockReactiveForms/test.spec.ts | 7 +++++-- 6 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/articles/extra/extensive-example.md b/docs/articles/extra/extensive-example.md index c0f750bcb6..55c62c3555 100644 --- a/docs/articles/extra/extensive-example.md +++ b/docs/articles/extra/extensive-example.md @@ -138,7 +138,7 @@ describe('main', () => { }); it('asserts behavior of AppComponent', () => { - const logoClickSpy = jasmine.createSpy(); + const logoClickSpy = jasmine.createSpy(); // or jest.fn(); // in case of jest // const logoClickSpy = jest.fn(); diff --git a/docs/articles/extra/mock-form-controls.md b/docs/articles/extra/mock-form-controls.md index 86a6bfb65e..05f161a132 100644 --- a/docs/articles/extra/mock-form-controls.md +++ b/docs/articles/extra/mock-form-controls.md @@ -100,7 +100,7 @@ describe('MockReactiveForms', () => { it('sends the correct value to the mock form component', () => { // That is our spy on writeValue calls. // With auto spy this code is not needed. - const writeValue = jasmine.createSpy('writeValue'); + const writeValue = jasmine.createSpy('writeValue'); // or jest.fn(); // in case of jest // const writeValue = jest.fn(); @@ -149,7 +149,7 @@ describe('MockForms', () => { it('sends the correct value to the mock form component', async () => { // That is our spy on writeValue calls. // With auto spy this code is not needed. - const writeValue = jasmine.createSpy('writeValue'); + const writeValue = jasmine.createSpy('writeValue'); // or jest.fn(); // in case of jest // const writeValue = jest.fn(); diff --git a/docs/articles/guides/http-interceptor.md b/docs/articles/guides/http-interceptor.md index df5ffc0c67..a7395d6b36 100644 --- a/docs/articles/guides/http-interceptor.md +++ b/docs/articles/guides/http-interceptor.md @@ -77,6 +77,7 @@ import { MockBuilder, MockRender, NG_MOCKS_INTERCEPTORS, + ngMocks, } from 'ng-mocks'; // An interceptor we want to test. diff --git a/docs/articles/guides/http-request.md b/docs/articles/guides/http-request.md index 119fa73bfe..eb744b292a 100644 --- a/docs/articles/guides/http-request.md +++ b/docs/articles/guides/http-request.md @@ -56,7 +56,7 @@ import { import { Injectable, NgModule } from '@angular/core'; import { Observable } from 'rxjs'; -import { MockBuilder, MockRender } from 'ng-mocks'; +import { MockBuilder, MockRender, ngMocks } from 'ng-mocks'; // A service that does http requests. @Injectable() diff --git a/docs/articles/guides/provider.md b/docs/articles/guides/provider.md index 1aabb748b8..ea5df5a105 100644 --- a/docs/articles/guides/provider.md +++ b/docs/articles/guides/provider.md @@ -258,7 +258,7 @@ describe('TestProviderWithUseClass', () => { it('respects all dependencies', () => { const service = MockRender< Target1Service & Partial - >(Target1Service).point.componentInstance; + >(Target1Service).point.componentInstance; // Let's assert that service has a flag from Target2Service. expect(service.flag).toBeTruthy(); @@ -397,7 +397,7 @@ describe('TestProviderWithUseExisting', () => { it('creates TargetService', () => { const service = MockRender< TargetService & Partial<{ name: string }> - >(TargetService).point.componentInstance; + >(TargetService).point.componentInstance; // Because Service2 has been replaced with a mock copy, // we are getting here a mock copy of Service2 instead of Service1. diff --git a/examples/MockReactiveForms/test.spec.ts b/examples/MockReactiveForms/test.spec.ts index 346e2d7ea4..cbc2fcf2eb 100644 --- a/examples/MockReactiveForms/test.spec.ts +++ b/examples/MockReactiveForms/test.spec.ts @@ -49,8 +49,11 @@ describe('MockReactiveForms', () => { MockInstance.scope(); beforeEach(() => { - return MockBuilder(MyComponent, ItsModule).keep( - ReactiveFormsModule, + // DependencyComponent is a declaration in ItsModule. + return ( + MockBuilder(MyComponent, ItsModule) + // ReactiveFormsModule is an import in ItsModule. + .keep(ReactiveFormsModule) ); });