@angular/material
Version:
Angular Material
30 lines (28 loc) • 21.4 kB
JavaScript
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/cdk/testing"),require("@angular/cdk/coercion")):"function"==typeof define&&define.amd?define("@angular/material/datepicker/testing",["exports","@angular/cdk/testing","@angular/cdk/coercion"],n):n(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.datepicker=t.ng.material.datepicker||{},t.ng.material.datepicker.testing={}),t.ng.cdk.testing,t.ng.cdk.coercion)}(this,(function(t,n,e){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var r=function(t,n){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])})(t,n)};function i(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}r(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function o(t,n,e,r){return new(e||(e=Promise))((function(i,o){function s(t){try{a(r.next(t))}catch(t){o(t)}}function u(t){try{a(r.throw(t))}catch(t){o(t)}}function a(t){t.done?i(t.value):function n(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(s,u)}a((r=r.apply(t,n||[])).next())}))}function s(t,n){var e,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function a(o){if(e)throw new TypeError("Generator is already executing.");for(;s;)try{if(e=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=n.call(t,s)}catch(t){o=[6,t],r=0}finally{e=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function u(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,i,o=e.call(t),s=[];try{for(;(void 0===n||n-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(e=o.return)&&e.call(o)}finally{if(i)throw i.error}}return s}function a(){for(var t=[],n=0;n<arguments.length;n++)t=t.concat(u(arguments[n]));return t}function c(t,e){return new n.HarnessPredicate(t,e).addOption("value",e.value,(function(t,e){return n.HarnessPredicate.stringMatches(t.getValue(),e)})).addOption("placeholder",e.placeholder,(function(t,e){return n.HarnessPredicate.stringMatches(t.getPlaceholder(),e)}))}var h=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.prototype.isDisabled=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().getProperty("disabled")]}}))}))},n.prototype.isRequired=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().getProperty("required")]}}))}))},n.prototype.getValue=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[4,t.sent().getProperty("value")];case 2:return[2,t.sent()]}}))}))},n.prototype.setValue=function(t){return o(this,void 0,void 0,(function(){var n;return s(this,(function(e){switch(e.label){case 0:return[4,this.host()];case 1:return[4,(n=e.sent()).clear()];case 2:return e.sent(),t?[4,n.sendKeys(t)]:[3,4];case 3:e.sent(),e.label=4;case 4:return n.dispatchEvent?[4,n.dispatchEvent("change")]:[3,6];case 5:e.sent(),e.label=6;case 6:return[2]}}))}))},n.prototype.getPlaceholder=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[4,t.sent().getProperty("placeholder")];case 2:return[2,t.sent()]}}))}))},n.prototype.focus=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().focus()]}}))}))},n.prototype.blur=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().blur()]}}))}))},n.prototype.isFocused=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().isFocused()]}}))}))},n.prototype.getMin=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().getAttribute("min")]}}))}))},n.prototype.getMax=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().getAttribute("max")]}}))}))},n}(n.ComponentHarness),l=function(t){function e(){var n=t.apply(this,a(arguments))||this;return n._content=n.locatorFor(".mat-calendar-body-cell-content"),n}return i(e,t),e.with=function(t){var r=this;return void 0===t&&(t={}),new n.HarnessPredicate(e,t).addOption("text",t.text,(function(t,e){return n.HarnessPredicate.stringMatches(t.getText(),e)})).addOption("selected",t.selected,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,t.isSelected()];case 1:return[2,e.sent()===n]}}))}))})).addOption("active",t.active,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,t.isActive()];case 1:return[2,e.sent()===n]}}))}))})).addOption("disabled",t.disabled,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,t.isDisabled()];case 1:return[2,e.sent()===n]}}))}))})).addOption("today",t.today,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,t.isToday()];case 1:return[2,e.sent()===n]}}))}))})).addOption("inRange",t.inRange,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,t.isInRange()];case 1:return[2,e.sent()===n]}}))}))})).addOption("inComparisonRange",t.inComparisonRange,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,t.isInComparisonRange()];case 1:return[2,e.sent()===n]}}))}))})).addOption("inPreviewRange",t.inPreviewRange,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(e){switch(e.label){case 0:return[4,t.isInPreviewRange()];case 1:return[2,e.sent()===n]}}))}))}))},e.prototype.getText=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._content()];case 1:return[2,t.sent().text()]}}))}))},e.prototype.getAriaLabel=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().getAttribute("aria-label")]}}))}))},e.prototype.isSelected=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[4,t.sent().getAttribute("aria-selected")];case 2:return[2,"true"===t.sent()]}}))}))},e.prototype.isDisabled=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("disabled")]}))}))},e.prototype.isActive=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("active")]}))}))},e.prototype.isToday=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._content()];case 1:return[2,t.sent().hasClass("mat-calendar-body-today")]}}))}))},e.prototype.select=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().click()]}}))}))},e.prototype.hover=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().hover()]}}))}))},e.prototype.mouseAway=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().mouseAway()]}}))}))},e.prototype.focus=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().focus()]}}))}))},e.prototype.blur=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().blur()]}}))}))},e.prototype.isRangeStart=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("range-start")]}))}))},e.prototype.isRangeEnd=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("range-end")]}))}))},e.prototype.isInRange=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("in-range")]}))}))},e.prototype.isComparisonRangeStart=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("comparison-start")]}))}))},e.prototype.isComparisonRangeEnd=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("comparison-end")]}))}))},e.prototype.isInComparisonRange=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("in-comparison-range")]}))}))},e.prototype.isPreviewRangeStart=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("preview-start")]}))}))},e.prototype.isPreviewRangeEnd=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("preview-end")]}))}))},e.prototype.isInPreviewRange=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._hasState("in-preview")]}))}))},e.prototype._hasState=function(t){return o(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,this.host()];case 1:return[2,n.sent().hasClass("mat-calendar-body-"+t)]}}))}))},e}(n.ComponentHarness);l.hostSelector=".mat-calendar-body-cell";var d=function(t){function e(){var n=t.apply(this,a(arguments))||this;return n._periodButton=n.locatorFor(".mat-calendar-period-button"),n}return i(e,t),e.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(e,t)},e.prototype.getCells=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return s(this,(function(n){return[2,this.locatorForAll(l.with(t))()]}))}))},e.prototype.getCurrentView=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.locatorForOptional("mat-multi-year-view")()];case 1:return t.sent()?[2,2]:[4,this.locatorForOptional("mat-year-view")()];case 2:return t.sent()?[2,1]:[2,0]}}))}))},e.prototype.getCurrentViewLabel=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._periodButton()];case 1:return[2,t.sent().text()]}}))}))},e.prototype.changeView=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._periodButton()];case 1:return[2,t.sent().click()]}}))}))},e.prototype.next=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.locatorFor(".mat-calendar-next-button")()];case 1:return[2,t.sent().click()]}}))}))},e.prototype.previous=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.locatorFor(".mat-calendar-previous-button")()];case 1:return[2,t.sent().click()]}}))}))},e.prototype.selectCell=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var n;return s(this,(function(e){switch(e.label){case 0:return[4,this.getCells(t)];case 1:if(!(n=e.sent()).length)throw Error("Cannot find calendar cell matching filter "+JSON.stringify(t));return[4,n[0].select()];case 2:return e.sent(),[2]}}))}))},e}(n.ComponentHarness);d.hostSelector=".mat-calendar";var f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.openCalendar=function(){return o(this,void 0,void 0,(function(){var t,e,r=this;return s(this,(function(i){switch(i.label){case 0:return[4,n.parallel((function(){return[r.isDisabled(),r.hasCalendar()]}))];case 1:return t=u.apply(void 0,[i.sent(),2]),e=t[1],!t[0]&&e?[2,this._openCalendar()]:[2]}}))}))},e.prototype.closeCalendar=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.isCalendarOpen()];case 1:return t.sent()?[4,v(p(this.host()),this.documentRootLocatorFactory())]:[3,4];case 2:return t.sent(),[4,this.forceStabilize()];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},e.prototype.hasCalendar=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,p(this.host())];case 1:return[2,null!=t.sent()]}}))}))},e.prototype.getCalendar=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return s(this,(function(n){return[2,y(t,this.host(),this.documentRootLocatorFactory())]}))}))},e}(n.ComponentHarness);function p(t){return o(this,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,t];case 1:return[2,n.sent().getAttribute("data-mat-calendar")]}}))}))}function v(t,n){return o(this,void 0,void 0,(function(){var e,r;return s(this,(function(i){switch(i.label){case 0:return r=".",[4,t];case 1:return e=r+i.sent()+"-backdrop",[4,n.locatorFor(e)()];case 2:return[2,i.sent().click()]}}))}))}function y(t,n,e){return o(this,void 0,void 0,(function(){var r;return s(this,(function(i){switch(i.label){case 0:return[4,p(n)];case 1:if(!(r=i.sent()))throw Error("Element is not associated with a calendar");return[2,e.locatorFor(d.with(Object.assign(Object.assign({},t),{selector:"#"+r})))()]}}))}))}var b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.with=function(t){return void 0===t&&(t={}),c(e,t)},e.prototype.isCalendarOpen=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[4,t.sent().getAttribute("aria-owns")];case 2:return[2,null!=t.sent()]}}))}))},e.prototype.openCalendar=function(){return o(this,void 0,void 0,(function(){var t,e,r=this;return s(this,(function(i){switch(i.label){case 0:return[4,n.parallel((function(){return[r.isDisabled(),r.hasCalendar()]}))];case 1:return t=u.apply(void 0,[i.sent(),2]),e=t[1],t[0]||!e?[3,3]:[4,this.host()];case 2:return[2,i.sent().sendKeys({alt:!0},n.TestKey.DOWN_ARROW)];case 3:return[2]}}))}))},e.prototype.closeCalendar=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.isCalendarOpen()];case 1:return t.sent()?[4,v(p(this.host()),this.documentRootLocatorFactory())]:[3,4];case 2:return t.sent(),[4,this.forceStabilize()];case 3:t.sent(),t.label=4;case 4:return[2]}}))}))},e.prototype.hasCalendar=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,p(this.host())];case 1:return[2,null!=t.sent()]}}))}))},e.prototype.getCalendar=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return s(this,(function(n){return[2,y(t,this.host(),this.documentRootLocatorFactory())]}))}))},e}(h);b.hostSelector=".mat-datepicker-input";var g=function(t){function r(){var n=t.apply(this,a(arguments))||this;return n._button=n.locatorFor("button"),n}return i(r,t),r.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(r,t)},r.prototype.isCalendarOpen=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().hasClass("mat-datepicker-toggle-active")]}}))}))},r.prototype.isDisabled=function(){return o(this,void 0,void 0,(function(){var t,n;return s(this,(function(r){switch(r.label){case 0:return[4,this._button()];case 1:return t=r.sent(),n=e.coerceBooleanProperty,[4,t.getAttribute("disabled")];case 2:return[2,n.apply(void 0,[r.sent()])]}}))}))},r.prototype._openCalendar=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._button()];case 1:return[2,t.sent().click()]}}))}))},r}(f);g.hostSelector=".mat-datepicker-toggle";var w=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.with=function(t){return void 0===t&&(t={}),c(n,t)},n}(h);w.hostSelector=".mat-start-date";var m=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.with=function(t){return void 0===t&&(t={}),c(n,t)},n}(h);m.hostSelector=".mat-end-date";var C=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(e,t).addOption("value",t.value,(function(t,e){return n.HarnessPredicate.stringMatches(t.getValue(),e)}))},e.prototype.getValue=function(){return o(this,void 0,void 0,(function(){var t,e,r,i=this;return s(this,(function(o){switch(o.label){case 0:return[4,n.parallel((function(){return[i.getStartInput().then((function(t){return t.getValue()})),i.getEndInput().then((function(t){return t.getValue()})),i.getSeparator()]}))];case 1:return t=u.apply(void 0,[o.sent(),3]),r=t[2],[2,t[0]+((e=t[1])?" "+r+" "+e:"")]}}))}))},e.prototype.getStartInput=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.locatorFor(w)()]}))}))},e.prototype.getEndInput=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.locatorFor(m)()]}))}))},e.prototype.getSeparator=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.locatorFor(".mat-date-range-input-separator")()];case 1:return[2,t.sent().text()]}}))}))},e.prototype.isDisabled=function(){return o(this,void 0,void 0,(function(){var t,e,r=this;return s(this,(function(i){switch(i.label){case 0:return[4,n.parallel((function(){return[r.getStartInput().then((function(t){return t.isDisabled()})),r.getEndInput().then((function(t){return t.isDisabled()}))]}))];case 1:return t=u.apply(void 0,[i.sent(),2]),e=t[1],[2,t[0]&&e]}}))}))},e.prototype.isRequired=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().hasClass("mat-date-range-input-required")]}}))}))},e.prototype.isCalendarOpen=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getStartInput()];case 1:return[4,t.sent().host()];case 2:return[4,t.sent().getAttribute("aria-owns")];case 3:return[2,null!=t.sent()]}}))}))},e.prototype._openCalendar=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getStartInput()];case 1:return[4,t.sent().host()];case 2:return[2,t.sent().sendKeys({alt:!0},n.TestKey.DOWN_ARROW)]}}))}))},e}(f);C.hostSelector=".mat-date-range-input",
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
t.MatCalendarCellHarness=l,t.MatCalendarHarness=d,t.MatDateRangeInputHarness=C,t.MatDatepickerInputHarness=b,t.MatDatepickerToggleHarness=g,t.MatEndDateHarness=m,t.MatStartDateHarness=w,Object.defineProperty(t,"__esModule",{value:!0})}));