1
- import {
2
- inject ,
3
- async ,
4
- addProviders ,
5
- TestComponentBuilder ,
6
- ComponentFixture ,
7
- TestBed ,
8
- } from '@angular/core/testing' ;
1
+ import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
9
2
import { Component , DebugElement } from '@angular/core' ;
10
3
import { By } from '@angular/platform-browser' ;
11
4
import { TooltipPosition , MdTooltip } from '@angular2-material/tooltip/tooltip' ;
@@ -14,43 +7,35 @@ import {MdTooltipModule} from './tooltip';
14
7
15
8
16
9
describe ( 'MdTooltip' , ( ) => {
17
- let builder : TestComponentBuilder ;
18
10
let overlayContainerElement : HTMLElement ;
19
11
20
12
beforeEach ( async ( ( ) => {
21
13
TestBed . configureTestingModule ( {
22
14
imports : [ MdTooltipModule ] ,
23
15
declarations : [ BasicTooltipDemo ] ,
16
+ providers : [
17
+ { provide : OverlayContainer , useFactory : ( ) => {
18
+ overlayContainerElement = document . createElement ( 'div' ) ;
19
+ return { getContainerElement : ( ) => overlayContainerElement } ;
20
+ } }
21
+ ]
24
22
} ) ;
25
23
26
- addProviders ( [
27
- { provide : OverlayContainer , useFactory : ( ) => {
28
- overlayContainerElement = document . createElement ( 'div' ) ;
29
- return { getContainerElement : ( ) => overlayContainerElement } ;
30
- } }
31
- ] ) ;
32
-
33
24
TestBed . compileComponents ( ) ;
34
25
} ) ) ;
35
26
36
- beforeEach ( inject ( [ TestComponentBuilder ] , ( tcb : TestComponentBuilder ) => {
37
- builder = tcb ;
38
- } ) ) ;
39
-
40
27
describe ( 'basic usage' , ( ) => {
41
28
let fixture : ComponentFixture < BasicTooltipDemo > ;
42
29
let buttonDebugElement : DebugElement ;
43
30
let buttonElement : HTMLButtonElement ;
44
31
let tooltipDirective : MdTooltip ;
45
32
46
33
beforeEach ( async ( ( ) => {
47
- builder . createAsync ( BasicTooltipDemo ) . then ( f => {
48
- fixture = f ;
49
- fixture . detectChanges ( ) ;
50
- buttonDebugElement = fixture . debugElement . query ( By . css ( 'button' ) ) ;
51
- buttonElement = < HTMLButtonElement > buttonDebugElement . nativeElement ;
52
- tooltipDirective = buttonDebugElement . injector . get ( MdTooltip ) ;
53
- } ) ;
34
+ fixture = TestBed . createComponent ( BasicTooltipDemo ) ;
35
+ fixture . detectChanges ( ) ;
36
+ buttonDebugElement = fixture . debugElement . query ( By . css ( 'button' ) ) ;
37
+ buttonElement = < HTMLButtonElement > buttonDebugElement . nativeElement ;
38
+ tooltipDirective = buttonDebugElement . injector . get ( MdTooltip ) ;
54
39
} ) ) ;
55
40
56
41
it ( 'should show/hide on mouse enter/leave' , async ( ( ) => {
0 commit comments