@angular/cdk
Version:
Angular Material Component Development Kit
37 lines • 11.1 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("tslib")):"function"==typeof define&&define.amd?define("@angular/cdk/testing",["exports","tslib"],e):e(((t=t||self).ng=t.ng||{},t.ng.cdk=t.ng.cdk||{},t.ng.cdk.testing={}),t.tslib)}(this,(function(t,e){"use strict";
/**
* @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
*/var r,n=function(){function t(t){this.locatorFactory=t}return t.prototype.host=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){return[2,this.locatorFactory.rootElement]}))}))},t.prototype.documentRootLocatorFactory=function(){return this.locatorFactory.documentRootLocatorFactory()},t.prototype.locatorFor=function(){for(var t,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return(t=this.locatorFactory).locatorFor.apply(t,e.__spread(r))},t.prototype.locatorForOptional=function(){for(var t,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return(t=this.locatorFactory).locatorForOptional.apply(t,e.__spread(r))},t.prototype.locatorForAll=function(){for(var t,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return(t=this.locatorFactory).locatorForAll.apply(t,e.__spread(r))},t.prototype.forceStabilize=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){return[2,this.locatorFactory.forceStabilize()]}))}))},t.prototype.waitForTasksOutsideAngular=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){return[2,this.locatorFactory.waitForTasksOutsideAngular()]}))}))},t}(),o=function(){function t(t,e){this.harnessType=t,this._predicates=[],this._descriptions=[],this._addBaseOptions(e)}return t.stringMatches=function(t,r){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,t];case 1:return t=e.sent(),null===r?[2,null===t]:null===t?[2,!1]:[2,"string"==typeof r?t===r:r.test(t)]}}))}))},t.prototype.add=function(t,e){return this._descriptions.push(t),this._predicates.push(e),this},t.prototype.addOption=function(t,e,r){return void 0!==e&&this.add(t+" = "+function n(t){if(void 0===t)return"undefined";try{return JSON.stringify(t,(function(t,e){return e instanceof RegExp?"/"+e.toString()+"/":"string"==typeof e?e.replace("///g","\\/"):e})).replace(/"\/\//g,"\\/").replace(/\/\/"/g,"\\/").replace(/\\\//g,"/")}catch(t){return"{...}"}}
/**
* @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),(function(t){return r(t,e)})),this},t.prototype.filter=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r,n=this;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,Promise.all(t.map((function(t){return n.evaluate(t)})))];case 1:return r=e.sent(),[2,t.filter((function(t,e){return r[e]}))]}}))}))},t.prototype.evaluate=function(t){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,Promise.all(this._predicates.map((function(e){return e(t)})))];case 1:return[2,e.sent().reduce((function(t,e){return t&&e}),!0)]}}))}))},t.prototype.getDescription=function(){return this._descriptions.join(", ")},t.prototype.getSelector=function(){var t=this;return this._ancestor.split(",").map((function(e){return(e.trim()+" "+t.harnessType.hostSelector).trim()})).join(",")},t.prototype._addBaseOptions=function(t){var r=this;this._ancestor=t.ancestor||"",this._ancestor&&this._descriptions.push('has ancestor matching selector "'+this._ancestor+'"');var n=t.selector;void 0!==n&&this.add('host matches selector "'+n+'"',(function(t){return e.__awaiter(r,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,t.host()];case 1:return[2,e.sent().matchesSelector(n)]}}))}))}))},t}(),i=function(){function t(t){this.rawRootElement=t,this.rootElement=this.createTestElement(t)}return t.prototype.documentRootLocatorFactory=function(){return this.createEnvironment(this.getDocumentRoot())},t.prototype.locatorFor=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return function(){return a(t._getAllHarnessesAndTestElements(e),c(e))}},t.prototype.locatorForOptional=function(){for(var t=this,r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return function(){return e.__awaiter(t,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this._getAllHarnessesAndTestElements(r)];case 1:return[2,t.sent()[0]||null]}}))}))}},t.prototype.locatorForAll=function(){for(var t=this,e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return function(){return t._getAllHarnessesAndTestElements(e)}},t.prototype.harnessLoaderFor=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r;return e.__generator(this,(function(e){switch(e.label){case 0:return r=this.createEnvironment,[4,a(this.getAllRawElements(t),[u(t)])];case 1:return[2,r.apply(this,[e.sent()])]}}))}))},t.prototype.harnessLoaderForOptional=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this.getAllRawElements(t)];case 1:return[2,(r=e.sent())[0]?this.createEnvironment(r[0]):null]}}))}))},t.prototype.harnessLoaderForAll=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r=this;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this.getAllRawElements(t)];case 1:return[2,e.sent().map((function(t){return r.createEnvironment(t)}))]}}))}))},t.prototype.getHarness=function(t){return this.locatorFor(t)()},t.prototype.getAllHarnesses=function(t){return this.locatorForAll(t)()},t.prototype.getChildLoader=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r;return e.__generator(this,(function(e){switch(e.label){case 0:return r=this.createEnvironment,[4,a(this.getAllRawElements(t),[u(t)])];case 1:return[2,r.apply(this,[e.sent()])]}}))}))},t.prototype.getAllChildLoaders=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r=this;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this.getAllRawElements(t)];case 1:return[2,e.sent().map((function(t){return r.createEnvironment(t)}))]}}))}))},t.prototype.createComponentHarness=function(t,e){return new t(this.createEnvironment(e))},t.prototype._getAllHarnessesAndTestElements=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r,n,i,a,c,u,l,h,f,p=this;return e.__generator(this,(function(_){switch(_.label){case 0:return r=function d(t){var r,n,i=[],s=[],a=[],c=new Set;try{for(var u=e.__values(t),l=u.next();!l.done;l=u.next()){var h=l.value;if("string"==typeof h)i.push(h),a.push(h);else{var f=h instanceof o?h:new o(h,{});i.push(f),s.push(f),c.add(f.harnessType)}}}catch(t){r={error:t}}finally{try{l&&!l.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return{allQueries:i,harnessQueries:s,elementQueries:a,harnessTypes:c}}(t),n=r.allQueries,c=r.harnessTypes,[4,this.getAllRawElements(e.__spread(a=r.elementQueries,(i=r.harnessQueries).map((function(t){return t.getSelector()}))).join(","))];case 1:return u=_.sent(),l=0===a.length&&1===c.size||0===i.length,[4,Promise.all(u.map((function(t){return e.__awaiter(p,void 0,void 0,(function(){var r,o=this;return e.__generator(this,(function(e){switch(e.label){case 0:return r=this.createTestElement(t),[4,Promise.all(n.map((function(e){return o._getQueryResultForElement(e,t,r,l)})))];case 1:return[2,s(e.sent())]}}))}))})))];case 2:return h=_.sent(),[2,(f=[]).concat.apply(f,e.__spread(h))]}}))}))},t.prototype._getQueryResultForElement=function(t,r,n,o){return void 0===o&&(o=!1),e.__awaiter(this,void 0,void 0,(function(){var i,s,a;return e.__generator(this,(function(e){switch(e.label){case 0:return"string"!=typeof t?[3,3]:(i=o)?[3,2]:[4,n.matchesSelector(t)];case 1:i=e.sent(),e.label=2;case 2:return[2,i?n:null];case 3:return(s=o)?[3,5]:[4,n.matchesSelector(t.getSelector())];case 4:s=e.sent(),e.label=5;case 5:return s?(a=this.createComponentHarness(t.harnessType,r),[4,t.evaluate(a)]):[3,7];case 6:return[2,e.sent()?a:null];case 7:return[2,null]}}))}))},t}();function s(t){return e.__awaiter(this,void 0,void 0,(function(){var r,o,i,s,a,c,u,l;return e.__generator(this,(function(h){r=!1,o=new Set,i=[];try{for(s=e.__values(t),a=s.next();!a.done;a=s.next())(c=a.value)&&(c instanceof n?o.has(c.constructor)||(o.add(c.constructor),i.push(c)):r||(r=!0,i.push(c)))}catch(t){u={error:t}}finally{try{a&&!a.done&&(l=s.return)&&l.call(s)}finally{if(u)throw u.error}}return[2,i]}))}))}function a(t,r){return e.__awaiter(this,void 0,void 0,(function(){var n;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,t];case 1:if(null==(n=e.sent()[0]))throw Error("Failed to find element matching one of the following queries:\n"+r.map((function(t){return"("+t+")"})).join(",\n"));return[2,n]}}))}))}function c(t){return t.map((function(t){return"string"==typeof t?function e(t){return'TestElement for element matching selector: "'+t+'"'}(t):function r(t){var e=t instanceof o?t:new o(t,{}),r=e.harnessType;return r.name+' with host element matching selector: "'+r.hostSelector+'"'+(e.getDescription()?" satisfying the constraints: "+e.getDescription():"")}(t)}))}function u(t){return'HarnessLoader for element matching selector: "'+t+'"'}
/**
* @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
*/(r=t.TestKey||(t.TestKey={}))[r.BACKSPACE=0]="BACKSPACE",r[r.TAB=1]="TAB",r[r.ENTER=2]="ENTER",r[r.SHIFT=3]="SHIFT",r[r.CONTROL=4]="CONTROL",r[r.ALT=5]="ALT",r[r.ESCAPE=6]="ESCAPE",r[r.PAGE_UP=7]="PAGE_UP",r[r.PAGE_DOWN=8]="PAGE_DOWN",r[r.END=9]="END",r[r.HOME=10]="HOME",r[r.LEFT_ARROW=11]="LEFT_ARROW",r[r.UP_ARROW=12]="UP_ARROW",r[r.RIGHT_ARROW=13]="RIGHT_ARROW",r[r.DOWN_ARROW=14]="DOWN_ARROW",r[r.INSERT=15]="INSERT",r[r.DELETE=16]="DELETE",r[r.F1=17]="F1",r[r.F2=18]="F2",r[r.F3=19]="F3",r[r.F4=20]="F4",r[r.F5=21]="F5",r[r.F6=22]="F6",r[r.F7=23]="F7",r[r.F8=24]="F8",r[r.F9=25]="F9",r[r.F10=26]="F10",r[r.F11=27]="F11",r[r.F12=28]="F12",r[r.META=29]="META",
/**
* @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.ComponentHarness=n,t.HarnessEnvironment=i,t.HarnessPredicate=o,Object.defineProperty(t,"__esModule",{value:!0})}));