@@ -23,6 +23,8 @@ import {
23
23
} from '../core/keyboard/keycodes' ;
24
24
import { MdDatepickerIntl } from './datepicker-intl' ;
25
25
import { MdNativeDateModule } from '../core/datetime/index' ;
26
+ import { NoConflictStyleCompatibilityMode } from '../core' ;
27
+ import { MdButtonModule } from '../button/index' ;
26
28
27
29
28
30
// When constructing a Date, the month is zero-based. This can be confusing, since people are
@@ -35,6 +37,7 @@ describe('MdCalendar', () => {
35
37
beforeEach ( async ( ( ) => {
36
38
TestBed . configureTestingModule ( {
37
39
imports : [
40
+ MdButtonModule ,
38
41
MdNativeDateModule ,
39
42
] ,
40
43
declarations : [
@@ -444,18 +447,13 @@ describe('MdCalendar', () => {
444
447
let fixture : ComponentFixture < CalendarWithMinMax > ;
445
448
let testComponent : CalendarWithMinMax ;
446
449
let calendarElement : HTMLElement ;
447
- let prevButton : HTMLButtonElement ;
448
- let nextButton : HTMLButtonElement ;
449
450
let calendarInstance : MdCalendar < Date > ;
450
451
451
452
beforeEach ( ( ) => {
452
453
fixture = TestBed . createComponent ( CalendarWithMinMax ) ;
453
454
454
455
let calendarDebugElement = fixture . debugElement . query ( By . directive ( MdCalendar ) ) ;
455
456
calendarElement = calendarDebugElement . nativeElement ;
456
- prevButton =
457
- calendarElement . querySelector ( '.mat-calendar-previous-button' ) as HTMLButtonElement ;
458
- nextButton = calendarElement . querySelector ( '.mat-calendar-next-button' ) as HTMLButtonElement ;
459
457
calendarInstance = calendarDebugElement . componentInstance ;
460
458
testComponent = fixture . componentInstance ;
461
459
} ) ;
@@ -478,6 +476,9 @@ describe('MdCalendar', () => {
478
476
testComponent . startAt = new Date ( 2016 , FEB , 1 ) ;
479
477
fixture . detectChanges ( ) ;
480
478
479
+ let prevButton =
480
+ calendarElement . querySelector ( '.mat-calendar-previous-button' ) as HTMLButtonElement ;
481
+
481
482
expect ( prevButton . disabled ) . toBe ( false , 'previous button should not be disabled' ) ;
482
483
expect ( calendarInstance . _activeDate ) . toEqual ( new Date ( 2016 , FEB , 1 ) ) ;
483
484
@@ -497,6 +498,9 @@ describe('MdCalendar', () => {
497
498
testComponent . startAt = new Date ( 2017 , DEC , 1 ) ;
498
499
fixture . detectChanges ( ) ;
499
500
501
+ let nextButton =
502
+ calendarElement . querySelector ( '.mat-calendar-next-button' ) as HTMLButtonElement ;
503
+
500
504
expect ( nextButton . disabled ) . toBe ( false , 'next button should not be disabled' ) ;
501
505
expect ( calendarInstance . _activeDate ) . toEqual ( new Date ( 2017 , DEC , 1 ) ) ;
502
506
@@ -584,6 +588,37 @@ describe('MdCalendar', () => {
584
588
} ) ;
585
589
} ) ;
586
590
591
+ describe ( 'MdCalendar in compatibility mode' , ( ) => {
592
+ beforeEach ( async ( ( ) => {
593
+ TestBed . configureTestingModule ( {
594
+ imports : [
595
+ MdButtonModule ,
596
+ MdNativeDateModule ,
597
+ NoConflictStyleCompatibilityMode ,
598
+ ] ,
599
+ declarations : [
600
+ MdCalendar ,
601
+ MdCalendarBody ,
602
+ MdMonthView ,
603
+ MdYearView ,
604
+
605
+ // Test components.
606
+ StandardCalendar ,
607
+ ] ,
608
+ providers : [
609
+ MdDatepickerIntl ,
610
+ ] ,
611
+ } ) ;
612
+
613
+ TestBed . compileComponents ( ) ;
614
+ } ) ) ;
615
+
616
+ it ( 'should not throw on creation' , ( ) => {
617
+ let fixture = TestBed . createComponent ( StandardCalendar ) ;
618
+ expect ( ( ) => fixture . detectChanges ( ) ) . not . toThrow ( ) ;
619
+ } ) ;
620
+ } ) ;
621
+
587
622
588
623
@Component ( {
589
624
template : `<md-calendar [startAt]="startDate" [(selected)]="selected"></md-calendar>`
0 commit comments