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:
|
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' })
|
@Pipe({ name: 'initCaps' })
|
||||||
export class InitCapsPipe {
|
export class InitCapsPipe implements PipeTransform{
|
||||||
transform(value: string) {
|
transform(value: string) {
|
||||||
return value.toLowerCase().replace(/(?:^|\s)[a-z]/g, function(m) {
|
return value.toLowerCase().replace(/(?:^|\s)[a-z]/g, function(m) {
|
||||||
return m.toUpperCase();
|
return m.toUpperCase();
|
||||||
|
@ -65,12 +65,13 @@ code-example(format="" language="html" escape="html").
|
||||||
:marked
|
:marked
|
||||||
We are writing an Angular application afterall and
|
We are writing an Angular application afterall and
|
||||||
we were going to need Angular sooner or later. That time has come.
|
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="").
|
code-example(format="").
|
||||||
import {Pipe} from 'angular2/core';
|
import {Pipe, PipeTransform} from 'angular2/core';
|
||||||
|
|
||||||
@Pipe({ name: 'initCaps' })
|
@Pipe({ name: 'initCaps' })
|
||||||
export class InitCapsPipe { ... }
|
export class InitCapsPipe implements PipeTransform { ... }
|
||||||
:marked
|
:marked
|
||||||
**Open** `unit-tests.html`
|
**Open** `unit-tests.html`
|
||||||
|
|
||||||
|
@ -159,5 +160,4 @@ figure.image-display
|
||||||
|
|
||||||
What about testing parts that *are themselves asynchronous*?
|
What about testing parts that *are themselves asynchronous*?
|
||||||
|
|
||||||
Let's test a service with a public asynchronous method that fetches heroes
|
Let's test a service with a public asynchronous method that fetches heroes from a remote server.
|
||||||
from a remote server.
|
|
||||||
|
|
Loading…
Reference in New Issue