UNPKG

@angular/material

Version:
38 lines (36 loc) 15.1 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/testing"),require("@angular/material/divider/testing")):"function"==typeof define&&define.amd?define("@angular/material/list/testing",["exports","@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.ng.cdk.testing,t.ng.material.divider.testing)}(this,(function(t,e,n){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */var r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function i(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function o(t,e,n,r){return new(n||(n=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):new n((function(e){e(t.value)})).then(s,u)}a((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,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(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=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=e.call(t,s)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function u(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function a(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function c(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return 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 */ function l(t,n){return new e.HarnessPredicate(t,n).addOption("text",n.text,(function(t,n){return e.HarnessPredicate.stringMatches(t.getText(),n)}))}var h=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={}),new e.HarnessPredicate(n,t).addOption("text",t.text,(function(t,n){return e.HarnessPredicate.stringMatches(t.getText(),n)}))},n.prototype.getText=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().text()]}}))}))},n.hostSelector="[mat-subheader], [matSubheader]",n}(e.ComponentHarness),f=function(t){function e(){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 i(e,t),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.host()];case 1:return[2,t.sent().text()]}}))}))},e.prototype.getLinesText=function(){return o(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return e=(t=Promise).all,[4,this._lines()];case 1:return[2,e.apply(t,[n.sent().map((function(t){return t.text()}))])]}}))}))},e.prototype.hasAvatar=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._avatar()];case 1:return[2,!!t.sent()]}}))}))},e.prototype.hasIcon=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._icon()];case 1:return[2,!!t.sent()]}}))}))},e.prototype.getHarnessLoaderForContent=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this.locatorFactory.harnessLoaderFor(".mat-list-item-content")]}))}))},e}(e.ComponentHarness),d=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i(e,t),e.prototype.getItems=function(t){return o(this,void 0,void 0,(function(){return s(this,(function(e){return[2,this.locatorForAll(this._itemHarness.with(t))()]}))}))},e.prototype.getItemsGroupedBySubheader=function(t){return o(this,void 0,void 0,(function(){var e,n,r,i,o,a,c,l,f,d;return s(this,(function(s){switch(s.label){case 0:return e=[],n={items:[]},[4,this.getItemsWithSubheadersAndDividers({item:t,divider:!1})];case 1:r=s.sent(),s.label=2;case 2:s.trys.push([2,8,9,10]),i=u(r),o=i.next(),s.label=3;case 3:return o.done?[3,7]:(a=o.value)instanceof h?((void 0!==n.heading||n.items.length)&&e.push(n),c={},[4,a.getText()]):[3,5];case 4:return c.heading=s.sent(),c.items=[],n=c,[3,6];case 5:n.items.push(a),s.label=6;case 6:return o=i.next(),[3,3];case 7:return[3,10];case 8:return l=s.sent(),f={error:l},[3,10];case 9:try{o&&!o.done&&(d=i.return)&&d.call(i)}finally{if(f)throw f.error}return[7];case 10:return void 0===n.heading&&!n.items.length&&e.length||e.push(n),[2,e]}}))}))},e.prototype.getItemsGroupedByDividers=function(t){return o(this,void 0,void 0,(function(){var e,r,i,o,a,c,l;return s(this,(function(s){switch(s.label){case 0:return e=[[]],[4,this.getItemsWithSubheadersAndDividers({item:t,subheader:!1})];case 1:r=s.sent();try{for(i=u(r),o=i.next();!o.done;o=i.next())(a=o.value)instanceof n.MatDividerHarness?e.push([]):e[e.length-1].push(a)}catch(t){c={error:t}}finally{try{o&&!o.done&&(l=i.return)&&l.call(i)}finally{if(c)throw c.error}}return[2,e]}}))}))},e.prototype.getItemsWithSubheadersAndDividers=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){var e;return s(this,(function(r){return e=[],!1!==t.item&&e.push(this._itemHarness.with(t.item||{})),!1!==t.subheader&&e.push(h.with(t.subheader)),!1!==t.divider&&e.push(n.MatDividerHarness.with(t.divider)),[2,this.locatorForAll.apply(this,c(e))()]}))}))},e}(e.ComponentHarness),p=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=v,e}return i(n,t),n.with=function(t){return void 0===t&&(t={}),new e.HarnessPredicate(n,t)},n.hostSelector="mat-action-list",n}(d),v=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={}),l(e,t)},e.prototype.click=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.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.hostSelector=["mat-list-item","a[mat-list-item]","button[mat-list-item]"].map((function(t){return p.hostSelector+" "+t})).join(","),e}(f),m=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=y,e}return i(n,t),n.with=function(t){return void 0===t&&(t={}),new e.HarnessPredicate(n,t)},n.hostSelector="mat-list",n}(d),y=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={}),l(e,t)},e.hostSelector=["mat-list-item","a[mat-list-item]","button[mat-list-item]"].map((function(t){return m.hostSelector+" "+t})).join(","),e}(f),b=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=g,e}return i(n,t),n.with=function(t){return void 0===t&&(t={}),new e.HarnessPredicate(n,t)},n.hostSelector="mat-nav-list",n}(d),g=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return i(n,t),n.with=function(t){var r=this;return void 0===t&&(t={}),l(n,t).addOption("href",t.href,(function(t,n){return o(r,void 0,void 0,(function(){return s(this,(function(r){return[2,e.HarnessPredicate.stringMatches(t.getHref(),n)]}))}))}))},n.prototype.getHref=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("href")]}}))}))},n.prototype.click=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()]}}))}))},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.hostSelector=["mat-list-item","a[mat-list-item]","button[mat-list-item]"].map((function(t){return b.hostSelector+" "+t})).join(","),n}(f),w=function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemHarness=H,e}return i(n,t),n.with=function(t){return void 0===t&&(t={}),new e.HarnessPredicate(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[4,t.sent().getAttribute("aria-disabled")];case 2:return[2,"true"===t.sent()]}}))}))},n.prototype.selectItems=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return o(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this._getItems(t)];case 1:return e=n.sent(),[4,Promise.all(e.map((function(t){return t.select()})))];case 2:return n.sent(),[2]}}))}))},n.prototype.deselectItems=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return o(this,void 0,void 0,(function(){var e;return s(this,(function(n){switch(n.label){case 0:return[4,this._getItems(t)];case 1:return e=n.sent(),[4,Promise.all(e.map((function(t){return t.deselect()})))];case 2:return n.sent(),[2]}}))}))},n.prototype._getItems=function(t){return o(this,void 0,void 0,(function(){var e,n,r,i,o=this;return s(this,(function(s){switch(s.label){case 0:return t.length?(n=(e=(i=[]).concat).apply,r=[i],[4,Promise.all(t.map((function(t){return o.locatorForAll(H.with(t))()})))]):[2,this.getItems()];case 1:return[2,n.apply(e,r.concat([c.apply(void 0,[s.sent()])]))]}}))}))},n.hostSelector="mat-selection-list",n}(d),H=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._itemContent=e.locatorFor(".mat-list-item-content"),e}return i(e,t),e.with=function(t){var n=this;return void 0===t&&(t={}),l(e,t).addOption("is selected",t.selected,(function(t,e){return o(n,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,t.isSelected()];case 1:return[2,n.sent()===e]}}))}))}))},e.prototype.getCheckboxPosition=function(){return o(this,void 0,void 0,(function(){return s(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"]}}))}))},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){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()]}}))}))},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.toggle=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.select=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.isSelected()];case 1:return t.sent()?[2]:[2,this.toggle()]}}))}))},e.prototype.deselect=function(){return o(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.isSelected()];case 1:return t.sent()?[2,this.toggle()]:[2]}}))}))},e.hostSelector="mat-list-option",e}(f); /** * @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=p,t.MatActionListItemHarness=v,t.MatListHarness=m,t.MatListItemHarness=y,t.MatListOptionHarness=H,t.MatNavListHarness=b,t.MatNavListItemHarness=g,t.MatSelectionListHarness=w,Object.defineProperty(t,"__esModule",{value:!0})}));