|
1 | 1 | import {async, ComponentFixture, TestBed} from '@angular/core/testing';
|
2 |
| -import {Component} from '@angular/core'; |
| 2 | +import {Component, ViewChild} from '@angular/core'; |
3 | 3 | import {By} from '@angular/platform-browser';
|
4 | 4 | import {MdYearView} from './year-view';
|
5 | 5 | import {MdCalendarBody} from './calendar-body';
|
6 | 6 | import {MdNativeDateModule} from '../core/datetime/index';
|
7 |
| -import {FEB, JAN, MAR} from '../core/testing/month-constants'; |
| 7 | +import {FEB, JAN, JUL, JUN, MAR} from '../core/testing/month-constants'; |
8 | 8 |
|
9 | 9 | describe('MdYearView', () => {
|
10 | 10 | beforeEach(async(() => {
|
@@ -76,6 +76,16 @@ describe('MdYearView', () => {
|
76 | 76 | expect((cellEls[0] as HTMLElement).innerText.trim()).toBe('JAN');
|
77 | 77 | expect(cellEls[0].classList).toContain('mat-calendar-body-active');
|
78 | 78 | });
|
| 79 | + |
| 80 | + it('should allow selection of month with less days than current active date', () => { |
| 81 | + testComponent.date = new Date(2017, JUL, 31); |
| 82 | + fixture.detectChanges(); |
| 83 | + |
| 84 | + expect(testComponent.yearView._monthSelected(JUN)); |
| 85 | + fixture.detectChanges(); |
| 86 | + |
| 87 | + expect(testComponent.selected).toEqual(new Date(2017, JUN, 30)); |
| 88 | + }); |
79 | 89 | });
|
80 | 90 |
|
81 | 91 | describe('year view with date filter', () => {
|
@@ -108,6 +118,8 @@ describe('MdYearView', () => {
|
108 | 118 | class StandardYearView {
|
109 | 119 | date = new Date(2017, JAN, 5);
|
110 | 120 | selected = new Date(2017, MAR, 10);
|
| 121 | + |
| 122 | + @ViewChild(MdYearView) yearView: MdYearView<Date>; |
111 | 123 | }
|
112 | 124 |
|
113 | 125 |
|
|
0 commit comments