|
1 | 1 | import {inject, TestBed} from '@angular/core/testing';
|
2 | 2 | import * as momentNs from 'moment';
|
| 3 | +import {Moment} from 'moment'; |
3 | 4 | import {UtilsService} from '../common/services/utils/utils.service';
|
4 | 5 | import {MonthCalendarService} from './month-calendar.service';
|
5 | 6 | import {IMonth} from './month.model';
|
@@ -71,6 +72,34 @@ describe('Service: MonthCalendarService', () => {
|
71 | 72 | expect(service.isMonthDisabled(month.date, config1)).toBe(true);
|
72 | 73 | }));
|
73 | 74 |
|
| 75 | + it('should check the isDateDisabled when isMonthDisabledCallback provided', |
| 76 | + inject([MonthCalendarService], (service: MonthCalendarService) => { |
| 77 | + const month: IMonth = { |
| 78 | + date: moment('01`-01-2017', 'DD-MM-YYYY'), |
| 79 | + selected: false, |
| 80 | + currentMonth: false, |
| 81 | + disabled: false, |
| 82 | + text: moment('01-01-2017', 'DD-MM-YYYY').format('MMM') |
| 83 | + }; |
| 84 | + const config1: any = { |
| 85 | + isMonthDisabledCallback: (m: Moment) => { |
| 86 | + return m.get('M') % 2 === 0; |
| 87 | + } |
| 88 | + }; |
| 89 | + |
| 90 | + for (let i = 0; i < 12; i++) { |
| 91 | + console.log(month.date.get('M'), i % 2, service.isMonthDisabled(month.date, config1)); |
| 92 | + |
| 93 | + if (i % 2 === 0) { |
| 94 | + expect(service.isMonthDisabled(month.date, config1)).toBe(true); |
| 95 | + } else { |
| 96 | + expect(service.isMonthDisabled(month.date, config1)).toBe(false); |
| 97 | + } |
| 98 | + |
| 99 | + month.date.add(1, 'month'); |
| 100 | + } |
| 101 | + })); |
| 102 | + |
74 | 103 | it('should check getDayBtnText method',
|
75 | 104 | inject([MonthCalendarService], (service: MonthCalendarService) => {
|
76 | 105 | const date = moment('05-04-2017', 'DD-MM-YYYY');
|
|
0 commit comments