UNPKG

@angular/material

Version:
51 lines (49 loc) 10.3 kB
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@angular/cdk/testing")):"function"==typeof define&&define.amd?define("@angular/material/table/testing",["exports","@angular/cdk/testing"],n):n(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.table=t.ng.material.table||{},t.ng.material.table.testing={}),t.ng.cdk.testing)}(this,(function(t,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 e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])})(t,n)};function r(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}function o(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{l(r.next(t))}catch(t){i(t)}}function s(t){try{l(r.throw(t))}catch(t){i(t)}}function l(t){t.done?o(t.value):new e((function(n){n(t.value)})).then(u,s)}l((r=r.apply(t,n||[])).next())}))}function i(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function l(i){if(e)throw new TypeError("Generator is already executing.");for(;u;)try{if(e=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 u.label++,{value:i[1],done:!1};case 5:u.label++,r=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){u.label=i[1];break}if(6===i[0]&&u.label<o[1]){u.label=o[1],o=i;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(i);break}o[2]&&u.ops.pop(),u.trys.pop();continue}i=n.call(t,u)}catch(t){i=[6,t],r=0}finally{e=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function u(t,n){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var r,o,i=e.call(t),u=[];try{for(;(void 0===n||n-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return u} /** * @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 s=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.with=function(t){return void 0===t&&(t={}),c(n,t)},n.prototype.getText=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().text()]}}))}))},n.prototype.getColumnName=function(){return o(this,void 0,void 0,(function(){var t,n;return i(this,(function(e){switch(e.label){case 0:return[4,this.host()];case 1:return[4,e.sent().getAttribute("class")];case 2:if((t=e.sent())&&(n=t.split(" ").map((function(t){return t.trim()})).find((function(t){return t.startsWith("mat-column-")}))))return[2,n.split("mat-column-")[1]];throw Error("Could not determine column name of cell.")}}))}))},n.hostSelector=".mat-cell",n}(n.ComponentHarness),l=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.with=function(t){return void 0===t&&(t={}),c(n,t)},n.hostSelector=".mat-header-cell",n}(s),a=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.with=function(t){return void 0===t&&(t={}),c(n,t)},n.hostSelector=".mat-footer-cell",n}(s);function c(t,e){return new n.HarnessPredicate(t,e).addOption("text",e.text,(function(t,e){return n.HarnessPredicate.stringMatches(t.getText(),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 */var f=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(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 i(this,(function(n){return[2,this.locatorForAll(s.with(t))()]}))}))},e.prototype.getCellTextByIndex=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,d(this,t)]}))}))},e.prototype.getCellTextByColumnName=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,v(this)]}))}))},e.hostSelector=".mat-row",e}(n.ComponentHarness),h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(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 i(this,(function(n){return[2,this.locatorForAll(l.with(t))()]}))}))},e.prototype.getCellTextByIndex=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,d(this,t)]}))}))},e.prototype.getCellTextByColumnName=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,v(this)]}))}))},e.hostSelector=".mat-header-row",e}(n.ComponentHarness),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(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 i(this,(function(n){return[2,this.locatorForAll(a.with(t))()]}))}))},e.prototype.getCellTextByIndex=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,d(this,t)]}))}))},e.prototype.getCellTextByColumnName=function(){return o(this,void 0,void 0,(function(){return i(this,(function(t){return[2,v(this)]}))}))},e.hostSelector=".mat-footer-row",e}(n.ComponentHarness);function d(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return[4,t.getCells(n)];case 1:return e=r.sent(),[2,Promise.all(e.map((function(t){return t.getText()})))]}}))}))}function v(t){return o(this,void 0,void 0,(function(){var n,e;return i(this,(function(r){switch(r.label){case 0:return n={},[4,t.getCells()];case 1:return e=r.sent(),[4,Promise.all(e.map((function(t){return Promise.all([t.getColumnName(),t.getText()])})))];case 2:return r.sent().forEach((function(t){var e=u(t,2);return n[e[0]]=e[1]})),[2,n]}}))}))} /** * @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 y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.with=function(t){return void 0===t&&(t={}),new n.HarnessPredicate(e,t)},e.prototype.getHeaderRows=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.locatorForAll(h.with(t))()]}))}))},e.prototype.getRows=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.locatorForAll(f.with(t))()]}))}))},e.prototype.getFooterRows=function(t){return void 0===t&&(t={}),o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.locatorForAll(p.with(t))()]}))}))},e.prototype.getCellTextByIndex=function(){return o(this,void 0,void 0,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.getRows()];case 1:return t=n.sent(),[2,Promise.all(t.map((function(t){return t.getCellTextByIndex()})))]}}))}))},e.prototype.getCellTextByColumnName=function(){return o(this,void 0,void 0,(function(){var t,n,e,r,o,s,l;return i(this,(function(i){switch(i.label){case 0:return[4,Promise.all([this.getHeaderRows(),this.getFooterRows(),this.getRows()])];case 1:return t=u.apply(void 0,[i.sent(),3]),n=t[1],e=t[2],r={},[4,Promise.all([Promise.all(t[0].map((function(t){return t.getCellTextByColumnName()}))),Promise.all(n.map((function(t){return t.getCellTextByColumnName()}))),Promise.all(e.map((function(t){return t.getCellTextByColumnName()})))])];case 2:return o=u.apply(void 0,[i.sent(),3]),s=o[0],l=o[1],o[2].forEach((function(t){Object.keys(t).forEach((function(n){var e=t[n];r[n]||(r[n]={headerText:m(s,n),footerText:m(l,n),text:[]}),r[n].text.push(e)}))})),[2,r]}}))}))},e.hostSelector=".mat-table",e}(n.ComponentHarness);function m(t,n){var e=[];return t.forEach((function(t){Object.keys(t).forEach((function(r){r===n&&e.push(t[r])}))})),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 */ /** * @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.MatCellHarness=s,t.MatFooterCellHarness=a,t.MatFooterRowHarness=p,t.MatHeaderCellHarness=l,t.MatHeaderRowHarness=h,t.MatRowHarness=f,t.MatTableHarness=y,Object.defineProperty(t,"__esModule",{value:!0})}));