1
- import { async , ComponentFixture , TestBed } from '@angular/core/testing' ;
1
+ import { fakeAsync , ComponentFixture , TestBed } from '@angular/core/testing' ;
2
2
import { Component } from '@angular/core' ;
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { MatDividerModule } from './divider-module' ;
@@ -8,12 +8,10 @@ describe('MatDivider', () => {
8
8
9
9
let fixture : ComponentFixture < MatDividerTestComponent > ;
10
10
11
- beforeEach ( async ( ( ) => {
11
+ beforeEach ( fakeAsync ( ( ) => {
12
12
TestBed . configureTestingModule ( {
13
13
imports : [ MatDividerModule ] ,
14
- declarations : [
15
- MatDividerTestComponent
16
- ] ,
14
+ declarations : [ MatDividerTestComponent ] ,
17
15
} ) ;
18
16
19
17
TestBed . compileComponents ( ) ;
@@ -25,17 +23,27 @@ describe('MatDivider', () => {
25
23
fixture . detectChanges ( ) ;
26
24
27
25
const divider = fixture . debugElement . query ( By . css ( 'mat-divider' ) ) ;
28
- expect ( divider . nativeElement . className ) . toContain ( 'mat-divider' ) ;
29
- expect ( divider . nativeElement . className ) . toContain ( 'mat-divider-vertical' ) ;
26
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider' ) ;
27
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider-vertical' ) ;
28
+ } ) ;
29
+
30
+ it ( 'should apply horizontal class to horizontal divider' , ( ) => {
31
+ fixture . componentInstance . vertical = false ;
32
+ fixture . detectChanges ( ) ;
33
+
34
+ const divider = fixture . debugElement . query ( By . css ( 'mat-divider' ) ) ;
35
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider' ) ;
36
+ expect ( divider . nativeElement . classList ) . not . toContain ( 'mat-divider-vertical' ) ;
37
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider-horizontal' ) ;
30
38
} ) ;
31
39
32
40
it ( 'should apply inset class to inset divider' , ( ) => {
33
41
fixture . componentInstance . inset = true ;
34
42
fixture . detectChanges ( ) ;
35
43
36
44
const divider = fixture . debugElement . query ( By . css ( 'mat-divider' ) ) ;
37
- expect ( divider . nativeElement . className ) . toContain ( 'mat-divider' ) ;
38
- expect ( divider . nativeElement . className ) . toContain ( 'mat-divider-inset' ) ;
45
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider' ) ;
46
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider-inset' ) ;
39
47
} ) ;
40
48
41
49
it ( 'should apply inset and vertical classes to vertical inset divider' , ( ) => {
@@ -44,9 +52,9 @@ describe('MatDivider', () => {
44
52
fixture . detectChanges ( ) ;
45
53
46
54
const divider = fixture . debugElement . query ( By . css ( 'mat-divider' ) ) ;
47
- expect ( divider . nativeElement . className ) . toContain ( 'mat-divider' ) ;
48
- expect ( divider . nativeElement . className ) . toContain ( 'mat-divider-inset' ) ;
49
- expect ( divider . nativeElement . className ) . toContain ( 'mat-divider-vertical' ) ;
55
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider' ) ;
56
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider-inset' ) ;
57
+ expect ( divider . nativeElement . classList ) . toContain ( 'mat-divider-vertical' ) ;
50
58
} ) ;
51
59
52
60
it ( 'should add aria roles properly' , ( ) => {
0 commit comments