@@ -4,6 +4,7 @@ import { FormsModule } from '@angular/forms';
44import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
55import { configureTestSuite } from '../test-utils/configure-suite' ;
66import { UIInteractions , wait } from '../test-utils/ui-interactions.spec' ;
7+ import { ymd } from '../test-utils/helper-utils.spec' ;
78import { IgxCalendarComponent } from './public_api' ;
89import { IgxDatePickerComponent } from '../date-picker/public_api' ;
910import { DateRangeType } from '../core/dates' ;
@@ -72,7 +73,7 @@ describe('Multi-View Calendar - ', () => {
7273 } ) ;
7374
7475 it ( 'should change months views when viewDate is changed' , ( ) => {
75- const dates = [ new Date ( '2019-06-19' ) , new Date ( '2019-07-19' ) , new Date ( '2019-08-19' ) ] ;
76+ const dates = [ ymd ( '2019-06-19' ) , ymd ( '2019-07-19' ) , ymd ( '2019-08-19' ) ] ;
7677 const today = new Date ( Date . now ( ) ) ;
7778 expect ( calendar . monthsViewNumber ) . toBe ( 3 ) ;
7879 HelperTestFunctions . verifyMonthsViewNumber ( fixture , 3 , true ) ;
@@ -87,7 +88,7 @@ describe('Multi-View Calendar - ', () => {
8788 } ) ;
8889
8990 it ( 'should be able to change hideOutsideDays property runtime' , ( ) => {
90- calendar . viewDate = new Date ( '2019-07-19' ) ;
91+ calendar . viewDate = ymd ( '2019-07-19' ) ;
9192 fixture . detectChanges ( ) ;
9293
9394 expect ( calendar . hideOutsideDays ) . toBe ( false ) ;
@@ -147,7 +148,7 @@ describe('Multi-View Calendar - ', () => {
147148
148149 it ( 'selected event should be fired when selecting a date' , ( ) => {
149150 spyOn ( calendar . selected , 'emit' ) ;
150- const viewDate = new Date ( '2019-09-06' ) ;
151+ const viewDate = ymd ( '2019-09-06' ) ;
151152 calendar . viewDate = viewDate ;
152153 fixture . detectChanges ( ) ;
153154
@@ -181,17 +182,17 @@ describe('Multi-View Calendar - ', () => {
181182 } ) ;
182183
183184 describe ( 'KB Navigation test - ' , ( ) => {
184- const aug2019 = new Date ( '2019-08-19' ) ;
185- const sept2019 = new Date ( '2019-09-19' ) ;
186- const oct2019 = new Date ( '2019-10-19' ) ;
187- const nov2019 = new Date ( '2019-11-19' ) ;
188- const dec2019 = new Date ( '2019-12-19' ) ;
189- const jan2020 = new Date ( '2020-1 -19' ) ;
190- const feb2020 = new Date ( '2020-2 -19' ) ;
191- const march2020 = new Date ( '2020-3 -19' ) ;
192- const oct2021 = new Date ( '2021-10-19' ) ;
193- const nov2021 = new Date ( '2021-11-19' ) ;
194- const dec2021 = new Date ( '2021-12-19' ) ;
185+ const aug2019 = ymd ( '2019-08-19' ) ;
186+ const sept2019 = ymd ( '2019-09-19' ) ;
187+ const oct2019 = ymd ( '2019-10-19' ) ;
188+ const nov2019 = ymd ( '2019-11-19' ) ;
189+ const dec2019 = ymd ( '2019-12-19' ) ;
190+ const jan2020 = ymd ( '2020-01 -19' ) ;
191+ const feb2020 = ymd ( '2020-02 -19' ) ;
192+ const march2020 = ymd ( '2020-03 -19' ) ;
193+ const oct2021 = ymd ( '2021-10-19' ) ;
194+ const nov2021 = ymd ( '2021-11-19' ) ;
195+ const dec2021 = ymd ( '2021-12-19' ) ;
195196
196197 const dateRangeDescriptors = [
197198 { type : DateRangeType . Between , dateRange : [ new Date ( 2019 , 10 , 15 ) , new Date ( 2019 , 11 , 8 ) ] } ,
@@ -505,14 +506,14 @@ describe('Multi-View Calendar - ', () => {
505506
506507 expect ( calendar . activeDate . getDate ( ) ) . toEqual ( 17 ) ;
507508 expect ( calendar . activeDate . getFullYear ( ) ) . toEqual ( 2018 ) ;
508- HelperTestFunctions . verifyCalendarSubHeaders ( fixture , [ new Date ( '2018-10-19' ) , new Date ( '2018-11-19' ) , new Date ( '2018-12-19' ) ] ) ;
509+ HelperTestFunctions . verifyCalendarSubHeaders ( fixture , [ ymd ( '2018-10-19' ) , ymd ( '2018-11-19' ) , ymd ( '2018-12-19' ) ] ) ;
509510
510511 UIInteractions . triggerKeyDownEvtUponElem ( 'PageUp' , document . activeElement , true , false , true ) ;
511512 fixture . detectChanges ( ) ;
512513
513514 expect ( calendar . activeDate . getDate ( ) ) . toEqual ( 17 ) ;
514515 expect ( calendar . activeDate . getFullYear ( ) ) . toEqual ( 2017 ) ;
515- HelperTestFunctions . verifyCalendarSubHeaders ( fixture , [ new Date ( '2017-10-19' ) , new Date ( '2017-11-19' ) , new Date ( '2017-12-19' ) ] ) ;
516+ HelperTestFunctions . verifyCalendarSubHeaders ( fixture , [ ymd ( '2017-10-19' ) , ymd ( '2017-11-19' ) , ymd ( '2017-12-19' ) ] ) ;
516517 } ) ;
517518
518519 it ( 'Verify navigation with Shift plus pageDown' , fakeAsync ( ( ) => {
@@ -526,7 +527,7 @@ describe('Multi-View Calendar - ', () => {
526527
527528 expect ( calendar . activeDate . getDate ( ) ) . toEqual ( 17 ) ;
528529 expect ( calendar . activeDate . getFullYear ( ) ) . toEqual ( 2020 ) ;
529- HelperTestFunctions . verifyCalendarSubHeaders ( fixture , [ new Date ( '2020-10-19' ) , new Date ( '2020-11-19' ) , new Date ( '2020-12-19' ) ] ) ;
530+ HelperTestFunctions . verifyCalendarSubHeaders ( fixture , [ ymd ( '2020-10-19' ) , ymd ( '2020-11-19' ) , ymd ( '2020-12-19' ) ] ) ;
530531
531532 UIInteractions . triggerKeyDownEvtUponElem ( 'PageDown' , document . activeElement , true , false , true ) ;
532533 fixture . detectChanges ( ) ;
@@ -710,10 +711,10 @@ describe('Multi-View Calendar - ', () => {
710711 } ) ;
711712
712713 describe ( 'Selection tests - ' , ( ) => {
713- const septemberDate = new Date ( '2019-09-16' ) ;
714- const octoberDate = new Date ( '2019-10-16' ) ;
715- const novemberDate = new Date ( '2019-11-16' ) ;
716- const decemberDate = new Date ( '2019-12-16' ) ;
714+ const septemberDate = ymd ( '2019-09-16' ) ;
715+ const octoberDate = ymd ( '2019-10-16' ) ;
716+ const novemberDate = ymd ( '2019-11-16' ) ;
717+ const decemberDate = ymd ( '2019-12-16' ) ;
717718 beforeEach ( fakeAsync ( ( ) => {
718719 fixture = TestBed . createComponent ( MultiViewCalendarSampleComponent ) ;
719720 fixture . detectChanges ( ) ;
@@ -763,8 +764,8 @@ describe('Multi-View Calendar - ', () => {
763764 calendar . selection = 'multi' ;
764765 fixture . detectChanges ( ) ;
765766
766- const octoberFourth = new Date ( '2019-10-4 ' ) ;
767- const octoberThird = new Date ( '2019-10-3 ' ) ;
767+ const octoberFourth = ymd ( '2019-10-04 ' ) ;
768+ const octoberThird = ymd ( '2019-10-03 ' ) ;
768769 const secondMonthDates = HelperTestFunctions . getMonthViewDates ( fixture , 1 ) ;
769770 UIInteractions . simulateClickAndSelectEvent ( secondMonthDates [ 2 ] . firstChild ) ;
770771 fixture . detectChanges ( ) ;
@@ -820,11 +821,11 @@ describe('Multi-View Calendar - ', () => {
820821 fixture . detectChanges ( ) ;
821822
822823 calendar . selectDate ( [
823- new Date ( " 2019-10-29" ) ,
824- new Date ( " 2019-11-2" ) ,
825- new Date ( " 2019-10-31" ) ,
826- new Date ( " 2019-11-1" ) ,
827- new Date ( " 2019-10-30" ) ,
824+ ymd ( ' 2019-10-29' ) ,
825+ ymd ( ' 2019-11-02' ) ,
826+ ymd ( ' 2019-10-31' ) ,
827+ ymd ( ' 2019-11-01' ) ,
828+ ymd ( ' 2019-10-30' ) ,
828829 ] ) ;
829830 fixture . detectChanges ( ) ;
830831
@@ -837,10 +838,10 @@ describe('Multi-View Calendar - ', () => {
837838 calendar . selection = 'single' ;
838839 fixture . detectChanges ( ) ;
839840
840- calendar . selectDate ( new Date ( '2019-10-29' ) ) ;
841+ calendar . selectDate ( ymd ( '2019-10-29' ) ) ;
841842 fixture . detectChanges ( ) ;
842843
843- calendar . selectDate ( new Date ( '2019-10-30' ) ) ;
844+ calendar . selectDate ( ymd ( '2019-10-30' ) ) ;
844845 fixture . detectChanges ( ) ;
845846
846847 expect ( HelperTestFunctions . getMonthViewSelectedDates ( fixture , 1 ) . length ) . toBe ( 1 ) ;
@@ -922,17 +923,17 @@ describe('Multi-View Calendar - ', () => {
922923
923924 calendar . selectDate ( [ septemberDate ] ) ;
924925 fixture . detectChanges ( ) ;
925- calendar . selectDate ( [ new Date ( '2019-09-21' ) ] ) ;
926+ calendar . selectDate ( [ ymd ( '2019-09-21' ) ] ) ;
926927 fixture . detectChanges ( ) ;
927928
928929 expect ( HelperTestFunctions . getMonthViewSelectedDates ( fixture , 0 ) . length ) . toBe ( 2 ) ;
929930
930931
931- calendar . deselectDate ( [ septemberDate , new Date ( '2019-09-21' ) ] ) ;
932+ calendar . deselectDate ( [ septemberDate , ymd ( '2019-09-21' ) ] ) ;
932933 fixture . detectChanges ( ) ;
933934 expect ( HelperTestFunctions . getMonthViewSelectedDates ( fixture , 0 ) . length ) . toBe ( 0 ) ;
934935
935- calendar . selectDate ( [ septemberDate , new Date ( '2019-10-24' ) , octoberDate , novemberDate ] ) ;
936+ calendar . selectDate ( [ septemberDate , ymd ( '2019-10-24' ) , octoberDate , novemberDate ] ) ;
936937 fixture . detectChanges ( ) ;
937938
938939 expect ( HelperTestFunctions . getMonthViewSelectedDates ( fixture , 1 ) . length ) . toBe ( 2 ) ; // october
@@ -1047,7 +1048,7 @@ describe('Multi-View Calendar - ', () => {
10471048
10481049 let overlay = document . querySelector ( HelperTestFunctions . OVERLAY_CSSCLASS ) ;
10491050 HelperTestFunctions . verifyMonthsViewNumber ( overlay , 3 ) ;
1050- HelperTestFunctions . verifyCalendarSubHeaders ( overlay , [ new Date ( '2019-09-16' ) , new Date ( '2019-10-16' ) , new Date ( '2019-11-16' ) ] ) ;
1051+ HelperTestFunctions . verifyCalendarSubHeaders ( overlay , [ ymd ( '2019-09-16' ) , ymd ( '2019-10-16' ) , ymd ( '2019-11-16' ) ] ) ;
10511052
10521053 // close the datePicker
10531054 datePicker . close ( ) ;
@@ -1066,7 +1067,7 @@ describe('Multi-View Calendar - ', () => {
10661067
10671068 overlay = document . querySelector ( HelperTestFunctions . OVERLAY_CSSCLASS ) ;
10681069 HelperTestFunctions . verifyMonthsViewNumber ( overlay , 2 ) ;
1069- HelperTestFunctions . verifyCalendarSubHeaders ( overlay , [ new Date ( '2019-09-16' ) , new Date ( '2019-10-16' ) ] ) ;
1070+ HelperTestFunctions . verifyCalendarSubHeaders ( overlay , [ ymd ( '2019-09-16' ) , ymd ( '2019-10-16' ) ] ) ;
10701071
10711072 // clean up test
10721073 tick ( 350 ) ;
@@ -1128,7 +1129,7 @@ export class MultiViewCalendarSampleComponent {
11281129} )
11291130export class MultiViewDatePickerSampleComponent {
11301131 @ViewChild ( IgxDatePickerComponent , { static : true } ) public datePicker : IgxDatePickerComponent ;
1131- public date = new Date ( '2019-09-15' ) ;
1132+ public date = ymd ( '2019-09-15' ) ;
11321133 public monthViews = 3 ;
11331134}
11341135
0 commit comments