blob: da3949042f23f1bca1a8d4d4e88a39c0c3af75ba [file] [log] [blame]
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/testing"),require("@angular/core/testing"),require("rxjs/operators"),require("rxjs"),require("@angular/cdk/keycodes")):"function"==typeof define&&define.amd?define("@angular/cdk/testing/testbed",["exports","@angular/cdk/testing","@angular/core/testing","rxjs/operators","rxjs","@angular/cdk/keycodes"],t):t(((e=e||self).ng=e.ng||{},e.ng.cdk=e.ng.cdk||{},e.ng.cdk.testing=e.ng.cdk.testing||{},e.ng.cdk.testing.testbed={}),e.ng.cdk.testing,e.ng.core.testing,e.rxjs.operators,e.rxjs,e.ng.cdk.keycodes)}(this,(function(e,t,n,r,o,i){"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 s=function(e,t){return(s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function u(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{a(r.next(e))}catch(e){i(e)}}function u(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){e.done?o(e.value):function t(e){return e instanceof n?e:new n((function(t){t(e)}))}(e.value).then(s,u)}a((r=r.apply(e,t||[])).next())}))}function a(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function a(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}}function c(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function f(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(l(arguments[t]));return e}var d=Symbol("ProxyZone_PATCHED#stateObservable"),h=function(){function e(e){this._lastState=e,this._stateSubject=new o.BehaviorSubject(this._lastState?this._getTaskStateFromInternalZoneState(this._lastState):{stable:!0}),this.state=this._stateSubject}return e.prototype.onHasTask=function(e,t,n,r){t===n&&this._stateSubject.next(this._getTaskStateFromInternalZoneState(r))},e.prototype._getTaskStateFromInternalZoneState=function(e){return{stable:!e.macroTask&&!e.microTask}},e.setup=function(){if(void 0===Zone)throw Error("Could not find ZoneJS. For test harnesses running in TestBed, ZoneJS needs to be installed.");var t=Zone.ProxyZoneSpec;if(!t)throw Error("ProxyZoneSpec is needed for the test harnesses but could not be found. Please make sure that your environment includes zone.js/dist/zone-testing.js");var n=t.assertPresent();if(n[d])return n[d];var r=new e(n.lastTaskState),o=n.onHasTask.bind(n);return n.onHasTask=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];o.apply(void 0,f(e)),r.onHasTask.apply(r,f(e))},n[d]=r.state},e}();function y(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=!0);var r=document.createEvent("Event");return r.initEvent(e,t,n),r}function p(e,t,n){Object.defineProperty(e,t,{get:function(){return n},configurable:!0})}
/**
* @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
*/function v(e,t){return e.dispatchEvent(t),t}function b(e,t,n){return v(e,y(t,n))}function k(e,t,n,r,o){return v(e,function i(e,t,n,r){void 0===t&&(t=0),void 0===n&&(n=""),void 0===r&&(r={});var o=document.createEvent("KeyboardEvent"),i=o.preventDefault.bind(o);if(void 0!==o.initKeyEvent)o.initKeyEvent(e,!0,!0,window,r.control,r.alt,r.shift,r.meta,t);else{var s="";r.control&&(s+="Control "),r.alt&&(s+="Alt "),r.shift&&(s+="Shift "),r.meta&&(s+="Meta "),o.initKeyboardEvent(e,!0,!0,window,0,n,0,s.trim(),!1)}return p(o,"keyCode",t),p(o,"key",n),p(o,"ctrlKey",!!r.control),p(o,"altKey",!!r.alt),p(o,"shiftKey",!!r.shift),p(o,"metaKey",!!r.meta),o.preventDefault=function(){return p(o,"defaultPrevented",!0),i()},o}(t,n,r,o))}function m(e,t,n,r,o,i){return void 0===n&&(n=0),void 0===r&&(r=0),v(e,
/**
* @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
*/
function s(e,t,n,r,o){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o={});var i=document.createEvent("MouseEvent"),s=i.preventDefault.bind(i);return i.initMouseEvent(e,!0,!0,window,0,t,n,t,n,!!o.control,!!o.alt,!!o.shift,!!o.meta,r,null),p(i,"buttons",1),i.preventDefault=function(){return p(i,"defaultPrevented",!0),s()},i}(t,n,r,o,i))}
/**
* @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
*/
function g(e,t){var n=!1,r=function(){return n=!0};e.addEventListener(t,r),e[t](),e.removeEventListener(t,r),n||b(e,t)}function w(e){g(e,"focus")}var E,T=new Set(["text","email","hidden","password","search","tel","url"]);function _(e){var t=e.nodeName.toLowerCase();return"input"===t||"textarea"===t}function C(e){for(var t,n,r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];var s,u,a=r[0];"string"!=typeof a&&void 0===a.keyCode&&void 0===a.key?(s=a,u=r.slice(1)):(s={},u=r);var l=_(e),f=e.getAttribute("type")||"text",d=u.map((function(e){return"string"==typeof e?e.split("").map((function(e){return{keyCode:e.toUpperCase().charCodeAt(0),key:e}})):[e]})).reduce((function(e,t){return e.concat(t)}),[]),h="number"===f&&d.length>0?d.every((function(e){return"."!==e.key&&e.keyCode!==i.PERIOD})):T.has(f);w(e),h||(e.value=d.reduce((function(e,t){return e+(t.key||"")}),""));try{for(var y=c(d),p=y.next();!p.done;p=y.next()){var v=p.value;k(e,"keydown",v.keyCode,v.key,s),k(e,"keypress",v.keyCode,v.key,s),l&&v.key&&1===v.key.length&&h&&(e.value+=v.key,b(e,"input")),k(e,"keyup",v.keyCode,v.key,s)}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=y.return)&&n.call(y)}finally{if(t)throw t.error}}h||b(e,"input")}var S=((E={})[t.TestKey.BACKSPACE]={keyCode:i.BACKSPACE,key:"Backspace"},E[t.TestKey.TAB]={keyCode:i.TAB,key:"Tab"},E[t.TestKey.ENTER]={keyCode:i.ENTER,key:"Enter"},E[t.TestKey.SHIFT]={keyCode:i.SHIFT,key:"Shift"},E[t.TestKey.CONTROL]={keyCode:i.CONTROL,key:"Control"},E[t.TestKey.ALT]={keyCode:i.ALT,key:"Alt"},E[t.TestKey.ESCAPE]={keyCode:i.ESCAPE,key:"Escape"},E[t.TestKey.PAGE_UP]={keyCode:i.PAGE_UP,key:"PageUp"},E[t.TestKey.PAGE_DOWN]={keyCode:i.PAGE_DOWN,key:"PageDown"},E[t.TestKey.END]={keyCode:i.END,key:"End"},E[t.TestKey.HOME]={keyCode:i.HOME,key:"Home"},E[t.TestKey.LEFT_ARROW]={keyCode:i.LEFT_ARROW,key:"ArrowLeft"},E[t.TestKey.UP_ARROW]={keyCode:i.UP_ARROW,key:"ArrowUp"},E[t.TestKey.RIGHT_ARROW]={keyCode:i.RIGHT_ARROW,key:"ArrowRight"},E[t.TestKey.DOWN_ARROW]={keyCode:i.DOWN_ARROW,key:"ArrowDown"},E[t.TestKey.INSERT]={keyCode:i.INSERT,key:"Insert"},E[t.TestKey.DELETE]={keyCode:i.DELETE,key:"Delete"},E[t.TestKey.F1]={keyCode:i.F1,key:"F1"},E[t.TestKey.F2]={keyCode:i.F2,key:"F2"},E[t.TestKey.F3]={keyCode:i.F3,key:"F3"},E[t.TestKey.F4]={keyCode:i.F4,key:"F4"},E[t.TestKey.F5]={keyCode:i.F5,key:"F5"},E[t.TestKey.F6]={keyCode:i.F6,key:"F6"},E[t.TestKey.F7]={keyCode:i.F7,key:"F7"},E[t.TestKey.F8]={keyCode:i.F8,key:"F8"},E[t.TestKey.F9]={keyCode:i.F9,key:"F9"},E[t.TestKey.F10]={keyCode:i.F10,key:"F10"},E[t.TestKey.F11]={keyCode:i.F11,key:"F11"},E[t.TestKey.F12]={keyCode:i.F12,key:"F12"},E[t.TestKey.META]={keyCode:i.META,key:"Meta"},E),F=function(){function e(e,t){this.element=e,this._stabilize=t}return e.prototype.blur=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return function t(e){g(e,"blur")}(this.element),[4,this._stabilize()];case 1:return e.sent(),[2]}}))}))},e.prototype.clear=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(!_(this.element))throw Error("Attempting to clear an invalid element");return function t(e){w(e),e.value="",b(e,"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
*/(this.element),[4,this._stabilize()];case 1:return e.sent(),[2]}}))}))},e.prototype.click=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this._dispatchMouseEventSequence("click",e,0)];case 1:return t.sent(),[4,this._stabilize()];case 2:return t.sent(),[2]}}))}))},e.prototype.rightClick=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this._dispatchMouseEventSequence("contextmenu",e,2)];case 1:return t.sent(),[4,this._stabilize()];case 2:return t.sent(),[2]}}))}))},e.prototype.focus=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return w(this.element),[4,this._stabilize()];case 1:return e.sent(),[2]}}))}))},e.prototype.getCssValue=function(e){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this._stabilize()];case 1:return t.sent(),[2,getComputedStyle(this.element).getPropertyValue(e)]}}))}))},e.prototype.hover=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return this._dispatchPointerEventIfSupported("pointerenter"),m(this.element,"mouseenter"),[4,this._stabilize()];case 1:return e.sent(),[2]}}))}))},e.prototype.mouseAway=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return this._dispatchPointerEventIfSupported("pointerleave"),m(this.element,"mouseleave"),[4,this._stabilize()];case 1:return e.sent(),[2]}}))}))},e.prototype.sendKeys=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return u(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:return t=e.map((function(e){return"number"==typeof e?S[e]:e})),C.apply(void 0,f([this.element],t)),[4,this._stabilize()];case 1:return n.sent(),[2]}}))}))},e.prototype.text=function(e){return u(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,this._stabilize()];case 1:return n.sent(),(null==e?void 0:e.exclude)?[2,t._getTextWithExcludedElements(this.element,e.exclude)]:[2,(this.element.textContent||"").trim()]}}))}))},e.prototype.getAttribute=function(e){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this._stabilize()];case 1:return t.sent(),[2,this.element.getAttribute(e)]}}))}))},e.prototype.hasClass=function(e){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this._stabilize()];case 1:return t.sent(),[2,this.element.classList.contains(e)]}}))}))},e.prototype.getDimensions=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._stabilize()];case 1:return e.sent(),[2,this.element.getBoundingClientRect()]}}))}))},e.prototype.getProperty=function(e){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this._stabilize()];case 1:return t.sent(),[2,this.element[e]]}}))}))},e.prototype.setInputValue=function(e){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return this.element.value=e,[4,this._stabilize()];case 1:return t.sent(),[2]}}))}))},e.prototype.selectOptions=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return u(this,void 0,void 0,(function(){var t,n,r,o,i,s;return a(this,(function(u){switch(u.label){case 0:for(t=!1,n=this.element.querySelectorAll("option"),r=new Set(e),o=0;o<n.length;o++)s=(i=n[o]).selected,i.selected=r.has(o),i.selected!==s&&(t=!0,b(this.element,"change"));return t?[4,this._stabilize()]:[3,2];case 1:u.sent(),u.label=2;case 2:return[2]}}))}))},e.prototype.matchesSelector=function(e){return u(this,void 0,void 0,(function(){var t;return a(this,(function(n){switch(n.label){case 0:return[4,this._stabilize()];case 1:return n.sent(),[2,((t=Element.prototype).matches||t.msMatchesSelector).call(this.element,e)]}}))}))},e.prototype.isFocused=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,this._stabilize()];case 1:return e.sent(),[2,document.activeElement===this.element]}}))}))},e.prototype.dispatchEvent=function(e,t){return u(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return n=y(e),t&&Object.assign(n,t),v(this.element,n),[4,this._stabilize()];case 1:return r.sent(),[2]}}))}))},e.prototype._dispatchPointerEventIfSupported=function(e,t,n,r){"undefined"!=typeof PointerEvent&&PointerEvent&&function o(e,t,n,r,i){void 0===n&&(n=0),void 0===r&&(r=0),v(e,function s(e,t,n,r){return void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r={isPrimary:!0}),new PointerEvent(e,Object.assign({bubbles:!0,cancelable:!0,view:window,clientX:t,clientY:n},r))}(t,n,r,i))}(this.element,e,t,n,{isPrimary:!0,button:r})},e.prototype._dispatchMouseEventSequence=function(e,t,n){return u(this,void 0,void 0,(function(){var r,o,i,s,u,c,l,f;return a(this,(function(a){switch(a.label){case 0:return r=void 0,o=void 0,i={},t.length&&"object"==typeof t[t.length-1]&&(i=t.pop()),t.length?[4,this.getDimensions()]:[3,2];case 1:s=a.sent(),u=s.top,c=s.width,l=s.height,f="center"===t[0]?l/2:t[1],r=Math.round(s.left+("center"===t[0]?c/2:t[0])),o=Math.round(u+f),a.label=2;case 2:return this._dispatchPointerEventIfSupported("pointerdown",r,o,n),m(this.element,"mousedown",r,o,n,i),this._dispatchPointerEventIfSupported("pointerup",r,o,n),m(this.element,"mouseup",r,o,n,i),m(this.element,e,r,o,n,i),[4,this._stabilize()];case 3:return a.sent(),[2]}}))}))},e}(),A={queryFn:function(e,t){return t.querySelectorAll(e)}},P=!1,K=new Set;function x(){return null!=Zone.current.get("FakeAsyncTestZoneSpec")}function O(e){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return e.detectChanges(),x()?(n.flush(),[3,3]):[3,1];case 1:return[4,e.whenStable()];case 2:t.sent(),t.label=3;case 3:return[2]}}))}))}var R=function(e){function o(n,r,o){var i=e.call(this,n)||this;return i._fixture=r,i._destroyed=!1,i._options=Object.assign(Object.assign({},A),o),i._taskState=h.setup(),function s(e){K.size||t.handleAutoChangeDetectionStatus((function(e){var t=e.onDetectChangesNow;P=e.isDisabled,t&&Promise.all(Array.from(K).map(O)).then(t)})),K.add(e)}(r),r.componentRef.onDestroy((function(){!function e(n){K.delete(n),K.size||t.stopHandlingAutoChangeDetectionStatus()}(r),i._destroyed=!0})),i}return function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}s(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(o,e),o.loader=function(e,t){return new o(e.nativeElement,e,t)},o.documentRootLoader=function(e,t){return new o(document.body,e,t)},o.getNativeElement=function(e){if(e instanceof F)return e.element;throw Error("This TestElement was not created by the TestbedHarnessEnvironment")},o.harnessForFixture=function(e,t,n){return u(this,void 0,void 0,(function(){var r;return a(this,(function(i){switch(i.label){case 0:return[4,(r=new o(e.nativeElement,e,n)).forceStabilize()];case 1:return i.sent(),[2,r.createComponentHarness(t,e.nativeElement)]}}))}))},o.prototype.forceStabilize=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:if(P)return[3,2];if(this._destroyed)throw Error("Harness is attempting to use a fixture that has already been destroyed.");return[4,O(this._fixture)];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))},o.prototype.waitForTasksOutsideAngular=function(){return u(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return x()&&n.flush(),[4,this._taskState.pipe(r.takeWhile((function(e){return!e.stable}))).toPromise()];case 1:return e.sent(),[2]}}))}))},o.prototype.getDocumentRoot=function(){return document.body},o.prototype.createTestElement=function(e){var t=this;return new F(e,(function(){return t.forceStabilize()}))},o.prototype.createEnvironment=function(e){return new o(e,this._fixture,this._options)},o.prototype.getAllRawElements=function(e){return u(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.forceStabilize()];case 1:return t.sent(),[2,Array.from(this._options.queryFn(e,this.rawRootElement))]}}))}))},o}(t.HarnessEnvironment);
/**
* @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
*/e.TestbedHarnessEnvironment=R,e.UnitTestElement=F,Object.defineProperty(e,"__esModule",{value:!0})}));