|
| 1 | +import {DemoPage} from './app.po'; |
| 2 | +import * as moment from 'moment'; |
| 3 | +import {browser, ElementFinder} from 'protractor'; |
| 4 | + |
| 5 | +describe('dpDayPicker dayPicker', () => { |
| 6 | + |
| 7 | + let page: DemoPage; |
| 8 | + |
| 9 | + beforeEach(() => { |
| 10 | + page = new DemoPage(); |
| 11 | + page.navigateTo(); |
| 12 | + }); |
| 13 | + |
| 14 | + it('should check if go to current location btn is working as expected', () => { |
| 15 | + const currentMonth = moment().format('MMM, YYYY'); |
| 16 | + const currentYear = moment().format('YYYY'); |
| 17 | + const prevMonth = moment().subtract(1, 'month').format('MMM, YYYY'); |
| 18 | + const prevYear = moment().subtract(1, 'year').format('YYYY'); |
| 19 | + |
| 20 | + const commonDayCalendar = (menu: ElementFinder, input: ElementFinder) => { |
| 21 | + menu.click(); |
| 22 | + input.click(); |
| 23 | + page.showGoToCurrentRadio.click(); |
| 24 | + expect(page.currentLocationBtn.isPresent()).toBe(true); |
| 25 | + expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(currentMonth); |
| 26 | + page.dayCalendarLeftNavBtn.click(); |
| 27 | + expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(prevMonth); |
| 28 | + page.currentLocationBtn.click(); |
| 29 | + expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(currentMonth); |
| 30 | + page.dayCalendarNavHeaderBtn.click(); |
| 31 | + expect(page.dayCalendarNavMonthHeaderBtn.getText()).toEqual(currentYear); |
| 32 | + page.monthCalendarLeftNavBtn.click(); |
| 33 | + expect(page.dayCalendarNavMonthHeaderBtn.getText()).toEqual(prevYear); |
| 34 | + page.dayCalendarNavMonthHeaderBtn.click(); |
| 35 | + |
| 36 | + page.currentLocationBtn.click(); |
| 37 | + expect(page.dayCalendarNavHeaderBtn.getText()).toEqual(currentMonth); |
| 38 | + |
| 39 | + page.hideGoToCurrentRadio.click(); |
| 40 | + input.click(); |
| 41 | + expect(page.currentLocationBtn.isPresent()).toBe(false); |
| 42 | + page.dayCalendarNavHeaderBtn.click(); |
| 43 | + expect(page.currentLocationBtn.isPresent()).toBe(false); |
| 44 | + }; |
| 45 | + |
| 46 | + const commonMonth = (menu: ElementFinder, input?: ElementFinder) => { |
| 47 | + menu.click(); |
| 48 | + input.click(); |
| 49 | + page.showGoToCurrentRadio.click(); |
| 50 | + expect(page.currentLocationBtn.isPresent()).toBe(true); |
| 51 | + expect(page.deyCalendarMonthNavHeader.getText()).toEqual(currentYear); |
| 52 | + page.monthCalendarLeftNavBtn.click(); |
| 53 | + expect(page.deyCalendarMonthNavHeader.getText()).toEqual(prevYear); |
| 54 | + page.currentLocationBtn.click(); |
| 55 | + expect(page.deyCalendarMonthNavHeader.getText()).toEqual(currentYear); |
| 56 | + |
| 57 | + page.hideGoToCurrentRadio.click(); |
| 58 | + input.click(); |
| 59 | + expect(page.currentLocationBtn.isPresent()).toBe(false); |
| 60 | + }; |
| 61 | + |
| 62 | + commonDayCalendar(page.daytimePickerMenu, page.daytimePickerInput); |
| 63 | + commonDayCalendar(page.daytimeDirectiveMenu, page.daytimeDirectiveInput); |
| 64 | + |
| 65 | + commonDayCalendar(page.dayPickerMenu, page.dayPickerInput); |
| 66 | + commonDayCalendar(page.dayDirectiveMenu, page.dayDirectiveInput); |
| 67 | + commonDayCalendar(page.dayDirectiveReactiveMenu, page.dayDirectiveReactiveInput); |
| 68 | + |
| 69 | + commonMonth(page.monthPickerMenu, page.monthPickerInput); |
| 70 | + commonMonth(page.monthDirectiveMenu, page.monthDirectiveInput); |
| 71 | + }); |
| 72 | + |
| 73 | + it('should hide current date button when not between min and max', () => { |
| 74 | + page.dayPickerMenu.click(); |
| 75 | + page.minSelectableInput.sendKeys(moment().add(3, 'month').format('DD-MM-YYYY')); |
| 76 | + page.dayPickerInput.click(); |
| 77 | + expect(page.currentLocationBtn.isPresent()).toBe(false); |
| 78 | + }); |
| 79 | +}); |
0 commit comments