Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit b5ffe70

Browse files
committed
docs(testing): simplify extracting directive
1 parent 4bbaac1 commit b5ffe70

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

public/docs/_examples/testing/ts/app/app.component.spec.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ describe('AppComponent', () => {
5151

5252
let links = fixture.debugElement
5353
.queryAll(By.directive(MockRouterLink))
54-
.map(de => <MockRouterLink> extractDirective(de, MockRouterLink));
54+
.map(de => <MockRouterLink> de.injector.get(MockRouterLink) );
5555

5656
expect(links.length).toEqual(2, 'should have 2 links');
5757
expect(links[0].routeParams[0]).toEqual('Dashboard', '1st link should go to Dashboard');
@@ -70,7 +70,7 @@ describe('AppComponent', () => {
7070

7171
expect(heroesDe).toBeDefined('should have a 2nd RouterLink');
7272

73-
let link = <MockRouterLink> extractDirective(heroesDe, MockRouterLink);
73+
let link = <MockRouterLink> heroesDe.injector.get(MockRouterLink);
7474

7575
expect(link.navigatedTo).toBeNull('link should not have navigate yet');
7676

@@ -82,15 +82,3 @@ describe('AppComponent', () => {
8282
});
8383
});
8484

85-
///////////// Helpers ////////////////////
86-
87-
import { Type } from 'angular2/src/facade/lang';
88-
89-
/**
90-
* Get the directive instance from the DebugElement to which it is attached
91-
*/
92-
function extractDirective(de: DebugElement, directive: Type): any {
93-
return de.injector.get(
94-
de.providerTokens[de.providerTokens.indexOf(directive)]
95-
);
96-
}

0 commit comments

Comments
 (0)