import {DemoPage} from './app.po'; import {browser} from 'protractor'; describe('dpDayPicker reactive directive', () => { let page: DemoPage; beforeEach(() => { page = new DemoPage(); page.navigateTo(); page.dateFormatInput.clear(); page.dateFormatInput.sendKeys('DD-MM-YYYY'); page.dayDirectiveReactiveMenu.click(); }); it('should check that the popup appended to body', () => { page.dayDirectiveReactiveInput.click(); expect(page.datePickerPopup.isDisplayed()).toBe(true); page.clickOnBody(); expect(page.datePickerPopup.isDisplayed()).toBe(false); }); it('should check that the theme is added and removed', () => { page.themeOnRadio.click(); expect(page.datePickerPopup.getAttribute('class')).toContain('dp-material'); page.themeOffRadio.click(); expect(page.datePickerPopup.getAttribute('class')).not.toContain('dp-material'); page.themeOnRadio.click(); expect(page.datePickerPopup.getAttribute('class')).toContain('dp-material'); }); it('should check that the onOpenDelay is working', () => { page.onOpenDelayInput.clear(); page.onOpenDelayInput.sendKeys(1000); page.scrollIntoView(page.openBtn); page.openBtn.click(); expect(page.datePickerPopup.isDisplayed()).toBe(true); page.clickOnBody(); browser.sleep(200); browser.waitForAngularEnabled(false); page.dayDirectiveReactiveInput.click(); expect(page.datePickerPopup.isDisplayed()).toBe(false); browser.waitForAngularEnabled(true); browser.sleep(1000); expect(page.datePickerPopup.isDisplayed()).toBe(true); }); it('should check if enable/disable required validation is working', () => { page.dayDirectiveReactiveInput.clear(); expect(page.reactiveRequiredValidationMsg.isPresent()).toBe(false); page.enableRequiredValidationRadio.click(); expect(page.reactiveRequiredValidationMsg.getText()).toEqual('required'); page.disableRequiredValidationRadio.click(); expect(page.reactiveRequiredValidationMsg.isPresent()).toBe(false); }); it('should check if min date validation is working', () => { page.minDateValidationPickerInput.clear(); expect(page.reactiveMinDateValidationMsg.isPresent()).toBe(false); page.minDateValidationPickerInput.sendKeys('11-04-2017'); page.dayDirectiveReactiveInput.sendKeys('10-04-2017'); page.clickOnBody(); expect(page.reactiveMinDateValidationMsg.getText()).toEqual('minDate invalid'); page.minDateValidationPickerInput.clear(); page.minDateValidationPickerInput.sendKeys('10-04-2017'); expect(page.reactiveMinDateValidationMsg.isPresent()).toBe(false); }); it('should check if max date validation is working', () => { page.maxDateValidationPickerInput.clear(); expect(page.reactiveMaxDateValidationMsg.isPresent()).toBe(false); page.maxDateValidationPickerInput.sendKeys('11-04-2017'); page.dayDirectiveReactiveInput.sendKeys('12-04-2017'); page.clickOnBody(); expect(page.reactiveMaxDateValidationMsg.getText()).toEqual('maxDate invalid'); page.maxDateValidationPickerInput.clear(); page.maxDateValidationPickerInput.sendKeys('12-04-2017'); expect(page.reactiveMaxDateValidationMsg.isPresent()).toBe(false); }); });