docs(testing) Pipe example in test should implement PipeTransform
closes #809
This commit is contained in:
parent
561935629f
commit
72330dcbf1
|
@ -16,10 +16,10 @@ code-example(format="." language="html" escape="html").
|
|||
The code for `InitCapsPipe` in `init-caps-pipe.ts` is quite brief:
|
||||
|
||||
```
|
||||
import {Pipe} from 'angular2/core';
|
||||
import {Pipe, PipeTransform} from 'angular2/core';
|
||||
|
||||
@Pipe({ name: 'initCaps' })
|
||||
export class InitCapsPipe {
|
||||
export class InitCapsPipe implements PipeTransform{
|
||||
transform(value: string) {
|
||||
return value.toLowerCase().replace(/(?:^|\s)[a-z]/g, function(m) {
|
||||
return m.toUpperCase();
|
||||
|
@ -65,12 +65,13 @@ code-example(format="" language="html" escape="html").
|
|||
:marked
|
||||
We are writing an Angular application afterall and
|
||||
we were going to need Angular sooner or later. That time has come.
|
||||
The `InitCapsPipe` clearly depends on Angular as is clear in the first few lines:
|
||||
|
||||
The `InitCapsPipe` depends on Angular as is clear in the first few lines:
|
||||
code-example(format="").
|
||||
import {Pipe} from 'angular2/core';
|
||||
import {Pipe, PipeTransform} from 'angular2/core';
|
||||
|
||||
@Pipe({ name: 'initCaps' })
|
||||
export class InitCapsPipe { ... }
|
||||
export class InitCapsPipe implements PipeTransform { ... }
|
||||
:marked
|
||||
**Open** `unit-tests.html`
|
||||
|
||||
|
@ -159,5 +160,4 @@ figure.image-display
|
|||
|
||||
What about testing parts that *are themselves asynchronous*?
|
||||
|
||||
Let's test a service with a public asynchronous method that fetches heroes
|
||||
from a remote server.
|
||||
Let's test a service with a public asynchronous method that fetches heroes from a remote server.
|
||||
|
|
Loading…
Reference in New Issue