1
1
import { Component , DebugElement } from '@angular/core' ;
2
2
import { By } from '@angular/platform-browser' ;
3
- import { fakeAsync , ComponentFixture , TestBed } from '@angular/core/testing' ;
3
+ import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
4
4
import { MatChip , MatChipsModule } from './index' ;
5
- import { dispatchFakeEvent } from '@angular/cdk/testing' ;
6
5
7
6
describe ( 'Chip Remove' , ( ) => {
8
7
let fixture : ComponentFixture < any > ;
9
8
let testChip : TestChip ;
10
9
let chipDebugElement : DebugElement ;
11
10
let chipNativeElement : HTMLElement ;
12
11
13
- beforeEach ( fakeAsync ( ( ) => {
12
+ beforeEach ( async ( ( ) => {
14
13
TestBed . configureTestingModule ( {
15
14
imports : [ MatChipsModule ] ,
16
15
declarations : [
@@ -19,6 +18,9 @@ describe('Chip Remove', () => {
19
18
} ) ;
20
19
21
20
TestBed . compileComponents ( ) ;
21
+ } ) ) ;
22
+
23
+ beforeEach ( async ( ( ) => {
22
24
fixture = TestBed . createComponent ( TestChip ) ;
23
25
testChip = fixture . debugElement . componentInstance ;
24
26
fixture . detectChanges ( ) ;
@@ -28,14 +30,14 @@ describe('Chip Remove', () => {
28
30
} ) ) ;
29
31
30
32
describe ( 'basic behavior' , ( ) => {
31
- it ( 'should apply the `mat-chip-remove` CSS class' , ( ) => {
32
- const hrefElement = chipNativeElement . querySelector ( 'a' ) ! ;
33
+ it ( 'should applies the `mat-chip-remove` CSS class' , ( ) => {
34
+ let hrefElement = chipNativeElement . querySelector ( 'a' ) ! ;
33
35
34
36
expect ( hrefElement . classList ) . toContain ( 'mat-chip-remove' ) ;
35
37
} ) ;
36
38
37
- it ( 'should emit (remove) on click' , ( ) => {
38
- const hrefElement = chipNativeElement . querySelector ( 'a' ) ! ;
39
+ it ( 'should emits (remove) on click' , ( ) => {
40
+ let hrefElement = chipNativeElement . querySelector ( 'a' ) ! ;
39
41
40
42
testChip . removable = true ;
41
43
fixture . detectChanges ( ) ;
@@ -46,19 +48,6 @@ describe('Chip Remove', () => {
46
48
47
49
expect ( testChip . didRemove ) . toHaveBeenCalled ( ) ;
48
50
} ) ;
49
-
50
- it ( 'should prevent the default click action' , ( ) => {
51
- const hrefElement = chipNativeElement . querySelector ( 'a' ) ! ;
52
-
53
- testChip . removable = true ;
54
- fixture . detectChanges ( ) ;
55
-
56
- const event = dispatchFakeEvent ( hrefElement , 'click' ) ;
57
- fixture . detectChanges ( ) ;
58
-
59
- expect ( event . defaultPrevented ) . toBe ( true ) ;
60
- } ) ;
61
-
62
51
} ) ;
63
52
} ) ;
64
53
0 commit comments