@@ -7,14 +7,16 @@ import {
7
7
Calendar , IgxCalendarComponent , IgxCalendarModule , isLeap ,
8
8
monthRange , weekDay , WEEKDAYS
9
9
} from './public_api' ;
10
- import { UIInteractions } from '../test-utils/ui-interactions.spec' ;
10
+ import { UIInteractions , wait } from '../test-utils/ui-interactions.spec' ;
11
11
import { DateRangeDescriptor , DateRangeType } from '../core/dates/dateRange' ;
12
12
13
13
import { configureTestSuite } from '../test-utils/configure-suite' ;
14
14
import { IgxDayItemComponent } from './days-view/day-item.component' ;
15
15
import { HelperTestFunctions } from './calendar-helper-utils' ;
16
+ import { CalendarView } from './month-picker-base' ;
17
+ import { IViewDateChangeEventArgs } from './calendar-base' ;
16
18
17
- describe ( 'IgxCalendar - ' , ( ) => {
19
+ fdescribe ( 'IgxCalendar - ' , ( ) => {
18
20
19
21
it ( 'Should create proper calendar model' , ( ) => {
20
22
const calendar = new Calendar ( ) ;
@@ -1554,41 +1556,66 @@ describe('IgxCalendar - ', () => {
1554
1556
dom = fixture . debugElement ;
1555
1557
} ) ) ;
1556
1558
1557
- it ( 'Should navigate to the previous/next month via KB.' , fakeAsync ( ( ) => {
1559
+ fit ( 'Should navigate to the previous/next month via KB.' , fakeAsync ( ( ) => {
1560
+ fixture . detectChanges ( ) ;
1561
+ const next = dom . queryAll ( By . css ( HelperTestFunctions . CALENDAR_NEXT_BUTTON_CSSCLASS ) ) [ 0 ] ;
1558
1562
const prev = dom . queryAll ( By . css ( HelperTestFunctions . CALENDAR_PREV_BUTTON_CSSCLASS ) ) [ 0 ] ;
1563
+
1564
+ let previousValue = fixture . componentInstance . calendar . viewDate ;
1559
1565
prev . nativeElement . focus ( ) ;
1566
+ spyOn ( calendar . onViewDateChanged , 'emit' ) . and . callThrough ( ) ;
1560
1567
1561
1568
expect ( prev . nativeElement ) . toBe ( document . activeElement ) ;
1562
1569
1563
1570
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , prev . nativeElement ) ;
1564
- tick ( 100 ) ;
1565
1571
fixture . detectChanges ( ) ;
1572
+ const tt = flush ( ) ;
1573
+ tick ( 100 ) ;
1566
1574
1575
+ let eventArgs : IViewDateChangeEventArgs = { previousValue, currentValue : fixture . componentInstance . calendar . viewDate } ;
1576
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1577
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledWith ( eventArgs ) ;
1567
1578
expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( 4 ) ;
1568
1579
1569
- const next = dom . queryAll ( By . css ( HelperTestFunctions . CALENDAR_NEXT_BUTTON_CSSCLASS ) ) [ 0 ] ;
1570
1580
next . nativeElement . focus ( ) ;
1581
+ previousValue = fixture . componentInstance . calendar . viewDate ;
1571
1582
expect ( next . nativeElement ) . toBe ( document . activeElement ) ;
1572
1583
1573
1584
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , next . nativeElement ) ;
1574
- tick ( 100 ) ;
1585
+
1575
1586
fixture . detectChanges ( ) ;
1587
+ tick ( 100 ) ;
1576
1588
1589
+ eventArgs = { previousValue, currentValue : fixture . componentInstance . calendar . viewDate } ;
1590
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1591
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledWith ( eventArgs ) ;
1592
+
1593
+ previousValue = fixture . componentInstance . calendar . viewDate ;
1577
1594
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , next . nativeElement ) ;
1578
- tick ( 100 ) ;
1595
+
1579
1596
fixture . detectChanges ( ) ;
1597
+ tick ( 100 ) ;
1580
1598
1599
+ eventArgs = { previousValue, currentValue : fixture . componentInstance . calendar . viewDate } ;
1600
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1601
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledWith ( eventArgs ) ;
1581
1602
expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( 6 ) ;
1582
1603
} ) ) ;
1583
1604
1584
- it ( 'Should open years view, navigate through and select an year via KB.' , ( ) => {
1605
+ it ( 'Should open years view, navigate through and select an year via KB.' , fakeAsync ( ( ) => {
1585
1606
const year = dom . queryAll ( By . css ( HelperTestFunctions . CALENDAR_DATE_CSSCLASS ) ) [ 1 ] ;
1586
1607
year . nativeElement . focus ( ) ;
1587
1608
1588
1609
expect ( year . nativeElement ) . toBe ( document . activeElement ) ;
1589
1610
1611
+ spyOn ( calendar . onActiveViewChanged , 'emit' ) . and . callThrough ( ) ;
1612
+
1590
1613
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , document . activeElement ) ;
1591
1614
fixture . detectChanges ( ) ;
1615
+ tick ( ) ;
1616
+
1617
+ expect ( calendar . onActiveViewChanged . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1618
+ expect ( calendar . onActiveViewChanged . emit ) . toHaveBeenCalledWith ( CalendarView . DECADE ) ;
1592
1619
1593
1620
const years = dom . queryAll ( By . css ( HelperTestFunctions . YEAR_CSSCLASS ) ) ;
1594
1621
let currentYear = dom . query ( By . css ( HelperTestFunctions . CURRENT_YEAR_CSSCLASS ) ) ;
@@ -1609,20 +1636,33 @@ describe('IgxCalendar - ', () => {
1609
1636
currentYear = dom . query ( By . css ( HelperTestFunctions . CURRENT_YEAR_CSSCLASS ) ) ;
1610
1637
expect ( currentYear . nativeElement . textContent . trim ( ) ) . toMatch ( '2016' ) ;
1611
1638
1639
+ const previousValue = fixture . componentInstance . calendar . viewDate ;
1640
+ spyOn ( calendar . onViewDateChanged , 'emit' ) . and . callThrough ( ) ;
1641
+
1612
1642
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , currentYear . nativeElement ) ;
1643
+
1613
1644
fixture . detectChanges ( ) ;
1645
+ tick ( ) ;
1614
1646
1647
+ const eventArgs : IViewDateChangeEventArgs = { previousValue, currentValue : fixture . componentInstance . calendar . viewDate } ;
1648
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1649
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledWith ( eventArgs ) ;
1615
1650
expect ( calendar . viewDate . getFullYear ( ) ) . toEqual ( 2016 ) ;
1616
- } ) ;
1651
+ } ) ) ;
1617
1652
1618
- it ( 'Should open months view, navigate through and select a month via KB.' , ( ) => {
1653
+ it ( 'Should open months view, navigate through and select a month via KB.' , fakeAsync ( ( ) => {
1619
1654
const month = dom . queryAll ( By . css ( HelperTestFunctions . CALENDAR_DATE_CSSCLASS ) ) [ 0 ] ;
1620
1655
month . nativeElement . focus ( ) ;
1656
+ spyOn ( calendar . onActiveViewChanged , 'emit' ) . and . callThrough ( ) ;
1621
1657
1622
1658
expect ( month . nativeElement ) . toBe ( document . activeElement ) ;
1623
1659
1624
1660
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , document . activeElement ) ;
1625
1661
fixture . detectChanges ( ) ;
1662
+ tick ( ) ;
1663
+
1664
+ expect ( calendar . onActiveViewChanged . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1665
+ expect ( calendar . onActiveViewChanged . emit ) . toHaveBeenCalledWith ( CalendarView . YEAR ) ;
1626
1666
1627
1667
const months = dom . queryAll ( By . css ( HelperTestFunctions . MONTH_CSSCLASS ) ) ;
1628
1668
const currentMonth = dom . query ( By . css ( HelperTestFunctions . CURRENT_MONTH_CSSCLASS ) ) ;
@@ -1651,11 +1691,18 @@ describe('IgxCalendar - ', () => {
1651
1691
1652
1692
expect ( document . activeElement . textContent . trim ( ) ) . toMatch ( 'Sep' ) ;
1653
1693
1694
+ const previousValue = fixture . componentInstance . calendar . viewDate ;
1695
+ spyOn ( calendar . onViewDateChanged , 'emit' ) . and . callThrough ( ) ;
1696
+
1654
1697
UIInteractions . triggerKeyDownEvtUponElem ( 'Enter' , document . activeElement ) ;
1655
1698
fixture . detectChanges ( ) ;
1699
+ tick ( ) ;
1656
1700
1701
+ const eventArgs : IViewDateChangeEventArgs = { previousValue, currentValue : fixture . componentInstance . calendar . viewDate } ;
1702
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledTimes ( 1 ) ;
1703
+ expect ( calendar . onViewDateChanged . emit ) . toHaveBeenCalledWith ( eventArgs ) ;
1657
1704
expect ( calendar . viewDate . getMonth ( ) ) . toEqual ( 8 ) ;
1658
- } ) ;
1705
+ } ) ) ;
1659
1706
1660
1707
it ( 'Should navigate to the first enabled date from the previous month when using "arrow up" key.' , fakeAsync ( ( ) => {
1661
1708
const dateRangeDescriptors : DateRangeDescriptor [ ] = [ ] ;
0 commit comments