UNPKG

@angular/material

Version:
23 lines 12.9 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("tslib"),require("@angular/cdk/testing"),require("@angular/material/divider/testing")):"function"==typeof define&&define.amd?define("@angular/material/list/testing",["exports","tslib","@angular/cdk/testing","@angular/material/divider/testing"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.list=t.ng.material.list||{},t.ng.material.list.testing={}),t.tslib,t.ng.cdk.testing,t.ng.material.divider.testing)}(this,(function(t,e,n,r){"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 */function i(t,e){return new n.HarnessPredicate(t,e).addOption("text",e.text,(function(t,e){return n.HarnessPredicate.stringMatches(t.getText(),e)}))}var s=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e.__extends(r,t),r.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(r,t).addOption("text",t.text,(function(t,e){return n.HarnessPredicate.stringMatches(t.getText(),e)}))},r.prototype.getText=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().text()]}}))}))},r.hostSelector="[mat-subheader], [matSubheader]",r}(n.ComponentHarness),o=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._lines=e.locatorForAll("[mat-line], [matLine]"),e._avatar=e.locatorForOptional("[mat-list-avatar], [matListAvatar]"),e._icon=e.locatorForOptional("[mat-list-icon], [matListIcon]"),e}return e.__extends(n,t),n.prototype.getText=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().text()]}}))}))},n.prototype.getLinesText=function(){return e.__awaiter(this,void 0,void 0,(function(){var t,n;return e.__generator(this,(function(e){switch(e.label){case 0:return n=(t=Promise).all,[4,this._lines()];case 1:return[2,n.apply(t,[e.sent().map((function(t){return t.text()}))])]}}))}))},n.prototype.hasAvatar=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this._avatar()];case 1:return[2,!!t.sent()]}}))}))},n.prototype.hasIcon=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this._icon()];case 1:return[2,!!t.sent()]}}))}))},n.prototype.getHarnessLoaderForContent=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){return[2,this.locatorFactory.harnessLoaderFor(".mat-list-item-content")]}))}))},n}(n.ComponentHarness),a=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e.__extends(n,t),n.prototype.getItems=function(t){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,this.locatorForAll(this._itemHarness.with(t))()]}))}))},n.prototype.getItemsGroupedBySubheader=function(t){return e.__awaiter(this,void 0,void 0,(function(){var n,r,i,o,a,u,c,l,h,d;return e.__generator(this,(function(_){switch(_.label){case 0:return n=[],r={items:[]},[4,this.getItemsWithSubheadersAndDividers({item:t,divider:!1})];case 1:i=_.sent(),_.label=2;case 2:_.trys.push([2,8,9,10]),o=e.__values(i),a=o.next(),_.label=3;case 3:return a.done?[3,7]:(u=a.value)instanceof s?((void 0!==r.heading||r.items.length)&&n.push(r),c={},[4,u.getText()]):[3,5];case 4:return c.heading=_.sent(),c.items=[],r=c,[3,6];case 5:r.items.push(u),_.label=6;case 6:return a=o.next(),[3,3];case 7:return[3,10];case 8:return l=_.sent(),h={error:l},[3,10];case 9:try{a&&!a.done&&(d=o.return)&&d.call(o)}finally{if(h)throw h.error}return[7];case 10:return void 0===r.heading&&!r.items.length&&n.length||n.push(r),[2,n]}}))}))},n.prototype.getItemsGroupedByDividers=function(t){return e.__awaiter(this,void 0,void 0,(function(){var n,i,s,o,a,u,c;return e.__generator(this,(function(l){switch(l.label){case 0:return n=[[]],[4,this.getItemsWithSubheadersAndDividers({item:t,subheader:!1})];case 1:i=l.sent();try{for(s=e.__values(i),o=s.next();!o.done;o=s.next())(a=o.value)instanceof r.MatDividerHarness?n.push([]):n[n.length-1].push(a)}catch(t){u={error:t}}finally{try{o&&!o.done&&(c=s.return)&&c.call(s)}finally{if(u)throw u.error}}return[2,n]}}))}))},n.prototype.getItemsWithSubheadersAndDividers=function(t){return void 0===t&&(t={}),e.__awaiter(this,void 0,void 0,(function(){var n;return e.__generator(this,(function(i){return n=[],!1!==t.item&&n.push(this._itemHarness.with(t.item||{})),!1!==t.subheader&&n.push(s.with(t.subheader)),!1!==t.divider&&n.push(r.MatDividerHarness.with(t.divider)),[2,this.locatorForAll.apply(this,e.__spread(n))()]}))}))},n}(n.ComponentHarness),u=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=c,e}return e.__extends(r,t),r.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(r,t)},r.hostSelector="mat-action-list",r}(a),c=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e.__extends(n,t),n.with=function(t){return void 0===t&&(t={}),i(n,t)},n.prototype.click=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().click()]}}))}))},n.prototype.focus=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().focus()]}}))}))},n.prototype.blur=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().blur()]}}))}))},n.hostSelector=["mat-list-item","a[mat-list-item]","button[mat-list-item]"].map((function(t){return u.hostSelector+" "+t})).join(","),n}(o),l=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=h,e}return e.__extends(r,t),r.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(r,t)},r.hostSelector="mat-list",r}(a),h=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e.__extends(n,t),n.with=function(t){return void 0===t&&(t={}),i(n,t)},n.hostSelector=["mat-list-item","a[mat-list-item]","button[mat-list-item]"].map((function(t){return l.hostSelector+" "+t})).join(","),n}(o),d=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=_,e}return e.__extends(r,t),r.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(r,t)},r.hostSelector="mat-nav-list",r}(a),_=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e.__extends(r,t),r.with=function(t){var s=this;return void 0===t&&(t={}),i(r,t).addOption("href",t.href,(function(t,r){return e.__awaiter(s,void 0,void 0,(function(){return e.__generator(this,(function(e){return[2,n.HarnessPredicate.stringMatches(t.getHref(),r)]}))}))}))},r.prototype.getHref=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().getAttribute("href")]}}))}))},r.prototype.click=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().click()]}}))}))},r.prototype.focus=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().focus()]}}))}))},r.prototype.blur=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().blur()]}}))}))},r.hostSelector=["mat-list-item","a[mat-list-item]","button[mat-list-item]"].map((function(t){return d.hostSelector+" "+t})).join(","),r}(o),f=function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=p,e}return e.__extends(r,t),r.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(r,t)},r.prototype.isDisabled=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[4,t.sent().getAttribute("aria-disabled")];case 2:return[2,"true"===t.sent()]}}))}))},r.prototype.selectItems=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.__awaiter(this,void 0,void 0,(function(){var n;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this._getItems(t)];case 1:return n=e.sent(),[4,Promise.all(n.map((function(t){return t.select()})))];case 2:return e.sent(),[2]}}))}))},r.prototype.deselectItems=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.__awaiter(this,void 0,void 0,(function(){var n;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this._getItems(t)];case 1:return n=e.sent(),[4,Promise.all(n.map((function(t){return t.deselect()})))];case 2:return e.sent(),[2]}}))}))},r.prototype._getItems=function(t){return e.__awaiter(this,void 0,void 0,(function(){var n,r,i,s,o=this;return e.__generator(this,(function(a){switch(a.label){case 0:return t.length?(r=(n=(s=[]).concat).apply,i=[s],[4,Promise.all(t.map((function(t){return o.locatorForAll(p.with(t))()})))]):[2,this.getItems()];case 1:return[2,r.apply(n,i.concat([e.__spread.apply(void 0,[a.sent()])]))]}}))}))},r.hostSelector="mat-selection-list",r}(a),p=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemContent=e.locatorFor(".mat-list-item-content"),e}return e.__extends(n,t),n.with=function(t){var r=this;return void 0===t&&(t={}),i(n,t).addOption("is selected",t.selected,(function(t,n){return e.__awaiter(r,void 0,void 0,(function(){return e.__generator(this,(function(e){switch(e.label){case 0:return[4,t.isSelected()];case 1:return[2,e.sent()===n]}}))}))}))},n.prototype.getCheckboxPosition=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this._itemContent()];case 1:return[4,t.sent().hasClass("mat-list-item-content-reverse")];case 2:return[2,t.sent()?"after":"before"]}}))}))},n.prototype.isSelected=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(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()]}}))}))},n.prototype.isDisabled=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[4,t.sent().getAttribute("aria-disabled")];case 2:return[2,"true"===t.sent()]}}))}))},n.prototype.focus=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().focus()]}}))}))},n.prototype.blur=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().blur()]}}))}))},n.prototype.toggle=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().click()]}}))}))},n.prototype.select=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.isSelected()];case 1:return t.sent()?[2]:[2,this.toggle()]}}))}))},n.prototype.deselect=function(){return e.__awaiter(this,void 0,void 0,(function(){return e.__generator(this,(function(t){switch(t.label){case 0:return[4,this.isSelected()];case 1:return t.sent()?[2,this.toggle()]:[2]}}))}))},n.hostSelector="mat-list-option",n}(o); /** * @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.MatActionListHarness=u,t.MatActionListItemHarness=c,t.MatListHarness=l,t.MatListItemHarness=h,t.MatListOptionHarness=p,t.MatNavListHarness=d,t.MatNavListItemHarness=_,t.MatSelectionListHarness=f,Object.defineProperty(t,"__esModule",{value:!0})}));