@@ -23,6 +23,8 @@ import {
2323} from '../core/keyboard/keycodes' ;
2424import { MdDatepickerIntl } from './datepicker-intl' ;
2525import { MdNativeDateModule } from '../core/datetime/index' ;
26+ import { NoConflictStyleCompatibilityMode } from '../core' ;
27+ import { MdButtonModule } from '../button/index' ;
2628
2729
2830// When constructing a Date, the month is zero-based. This can be confusing, since people are
@@ -35,6 +37,7 @@ describe('MdCalendar', () => {
3537 beforeEach ( async ( ( ) => {
3638 TestBed . configureTestingModule ( {
3739 imports : [
40+ MdButtonModule ,
3841 MdNativeDateModule ,
3942 ] ,
4043 declarations : [
@@ -444,18 +447,13 @@ describe('MdCalendar', () => {
444447 let fixture : ComponentFixture < CalendarWithMinMax > ;
445448 let testComponent : CalendarWithMinMax ;
446449 let calendarElement : HTMLElement ;
447- let prevButton : HTMLButtonElement ;
448- let nextButton : HTMLButtonElement ;
449450 let calendarInstance : MdCalendar < Date > ;
450451
451452 beforeEach ( ( ) => {
452453 fixture = TestBed . createComponent ( CalendarWithMinMax ) ;
453454
454455 let calendarDebugElement = fixture . debugElement . query ( By . directive ( MdCalendar ) ) ;
455456 calendarElement = calendarDebugElement . nativeElement ;
456- prevButton =
457- calendarElement . querySelector ( '.mat-calendar-previous-button' ) as HTMLButtonElement ;
458- nextButton = calendarElement . querySelector ( '.mat-calendar-next-button' ) as HTMLButtonElement ;
459457 calendarInstance = calendarDebugElement . componentInstance ;
460458 testComponent = fixture . componentInstance ;
461459 } ) ;
@@ -478,6 +476,9 @@ describe('MdCalendar', () => {
478476 testComponent . startAt = new Date ( 2016 , FEB , 1 ) ;
479477 fixture . detectChanges ( ) ;
480478
479+ let prevButton =
480+ calendarElement . querySelector ( '.mat-calendar-previous-button' ) as HTMLButtonElement ;
481+
481482 expect ( prevButton . disabled ) . toBe ( false , 'previous button should not be disabled' ) ;
482483 expect ( calendarInstance . _activeDate ) . toEqual ( new Date ( 2016 , FEB , 1 ) ) ;
483484
@@ -497,6 +498,9 @@ describe('MdCalendar', () => {
497498 testComponent . startAt = new Date ( 2017 , DEC , 1 ) ;
498499 fixture . detectChanges ( ) ;
499500
501+ let nextButton =
502+ calendarElement . querySelector ( '.mat-calendar-next-button' ) as HTMLButtonElement ;
503+
500504 expect ( nextButton . disabled ) . toBe ( false , 'next button should not be disabled' ) ;
501505 expect ( calendarInstance . _activeDate ) . toEqual ( new Date ( 2017 , DEC , 1 ) ) ;
502506
@@ -584,6 +588,37 @@ describe('MdCalendar', () => {
584588 } ) ;
585589} ) ;
586590
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+
587622
588623@Component ( {
589624 template : `<md-calendar [startAt]="startDate" [(selected)]="selected"></md-calendar>`
0 commit comments