diff --git a/aio/content/examples/testing/src/app/hero/hero-detail.component.spec.ts b/aio/content/examples/testing/src/app/hero/hero-detail.component.spec.ts index 2326e3dded..2989c6e05a 100644 --- a/aio/content/examples/testing/src/app/hero/hero-detail.component.spec.ts +++ b/aio/content/examples/testing/src/app/hero/hero-detail.component.spec.ts @@ -197,20 +197,21 @@ function heroModuleSetup() { // #docregion title-case-pipe it('should convert hero name to Title Case', () => { - const inputName = 'quick BROWN fox'; - const titleCaseName = 'Quick Brown Fox'; - const { nameInput, nameDisplay } = page; + // get the name's input and display elements from the DOM + const hostElement = fixture.nativeElement; + const nameInput: HTMLInputElement = hostElement.querySelector('input'); + const nameDisplay: HTMLElement = hostElement.querySelector('span'); - // simulate user entering new name into the input box - nameInput.value = inputName; + // simulate user entering a new name into the input box + nameInput.value = 'quick BROWN fOx'; // dispatch a DOM event so that Angular learns of input value change. nameInput.dispatchEvent(newEvent('input')); - // Tell Angular to update the output span through the title pipe + // Tell Angular to update the display binding through the title pipe fixture.detectChanges(); - expect(nameDisplay.textContent).toBe(titleCaseName); + expect(nameDisplay.textContent).toBe('Quick Brown Fox'); }); // #enddocregion title-case-pipe // #enddocregion selected-tests diff --git a/aio/content/guide/testing.md b/aio/content/guide/testing.md index 22894476e2..d47c2d457a 100644 --- a/aio/content/guide/testing.md +++ b/aio/content/guide/testing.md @@ -785,6 +785,25 @@ There is no harm in calling `detectChanges()` more often than is strictly necess