UNPKG

@angular/material

Version:
37 lines (35 loc) 10.4 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/material/form-field/testing/control"),require("@angular/cdk/testing"),require("@angular/material/input/testing"),require("@angular/material/select/testing")):"function"==typeof define&&define.amd?define("@angular/material/form-field/testing",["exports","@angular/material/form-field/testing/control","@angular/cdk/testing","@angular/material/input/testing","@angular/material/select/testing"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.formField=t.ng.material.formField||{},t.ng.material.formField.testing={}),t.ng.material.formField.testing.control,t.ng.cdk.testing,t.ng.material.input.testing,t.ng.material.select.testing)}(this,(function(t,e,n,r,o){"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 i=function(t,e){return(i=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 a(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(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 n((function(e){e(t.value)})).then(a,s)}l((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,o,i,a={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(n)throw new TypeError("Generator is already executing.");for(;a;)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 a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a} /** * @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 u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._prefixContainer=e.locatorForOptional(".mat-form-field-prefix"),e._suffixContainer=e.locatorForOptional(".mat-form-field-suffix"),e._label=e.locatorForOptional(".mat-form-field-label"),e._errors=e.locatorForAll(".mat-error"),e._hints=e.locatorForAll("mat-hint, .mat-hint"),e._inputControl=e.locatorForOptional(r.MatInputHarness),e._selectControl=e.locatorForOptional(o.MatSelectHarness),e}return function u(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e.with=function(t){var r=this;return void 0===t&&(t={}),new n.HarnessPredicate(e,t).addOption("floatingLabelText",t.floatingLabelText,(function(t,e){return a(r,void 0,void 0,(function(){var r,o;return s(this,(function(i){switch(i.label){case 0:return o=(r=n.HarnessPredicate).stringMatches,[4,t.getLabel()];case 1:return[2,o.apply(r,[i.sent(),e])]}}))}))})).addOption("hasErrors",t.hasErrors,(function(t,e){return a(r,void 0,void 0,(function(){return s(this,(function(n){switch(n.label){case 0:return[4,t.hasErrors()];case 1:return[2,n.sent()===e]}}))}))}))},e.prototype.getAppearance=function(){return a(this,void 0,void 0,(function(){var t,e;return s(this,(function(n){switch(n.label){case 0:return[4,this.host()];case 1:return[4,n.sent().getAttribute("class")];case 2:if(null!==(t=n.sent())&&(e=t.match(/mat-form-field-appearance-(legacy|standard|fill|outline)(?:$| )/)))return[2,e[1]];throw Error("Could not determine appearance of form-field.")}}))}))},e.prototype.getControl=function(t){return a(this,void 0,void 0,(function(){var e,n,r;return s(this,(function(o){switch(o.label){case 0:return t?[2,this.locatorForOptional(t)()]:[4,this.host()];case 1:return e=o.sent(),[4,Promise.all([e.hasClass("mat-form-field-type-mat-input"),e.hasClass("mat-form-field-type-mat-select")])];case 2:return n=l.apply(void 0,[o.sent(),2]),r=n[1],n[0]?[2,this._inputControl()]:r?[2,this._selectControl()]:[2,null]}}))}))},e.prototype.hasLabel=function(){return a(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().hasClass("mat-form-field-has-label")]}}))}))},e.prototype.getLabel=function(){return a(this,void 0,void 0,(function(){var t;return s(this,(function(e){switch(e.label){case 0:return[4,this._label()];case 1:return[2,(t=e.sent())?t.text():null]}}))}))},e.prototype.hasErrors=function(){return a(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this.getTextErrors()];case 1:return[2,t.sent().length>0]}}))}))},e.prototype.isLabelFloating=function(){return a(this,void 0,void 0,(function(){var t,e,n,r,o;return s(this,(function(i){switch(i.label){case 0:return r=(n=Promise).all,o=[this.hasLabel()],[4,this.host()];case 1:return[4,r.apply(n,[o.concat([i.sent().hasClass("mat-form-field-should-float")])])];case 2:return t=l.apply(void 0,[i.sent(),2]),e=t[1],[2,t[0]&&e]}}))}))},e.prototype.isDisabled=function(){return a(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().hasClass("mat-form-field-disabled")]}}))}))},e.prototype.isAutofilled=function(){return a(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().hasClass("mat-form-field-autofilled")]}}))}))},e.prototype.getThemeColor=function(){return a(this,void 0,void 0,(function(){var t,e,n;return s(this,(function(r){switch(r.label){case 0:return[4,this.host()];case 1:return t=r.sent(),[4,Promise.all([t.hasClass("mat-accent"),t.hasClass("mat-warn")])];case 2:return e=l.apply(void 0,[r.sent(),2]),n=e[1],e[0]?[2,"accent"]:n?[2,"warn"]:[2,"primary"]}}))}))},e.prototype.getTextErrors=function(){return a(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._errors()];case 1:return[2,e.apply(t,[n.sent().map((function(t){return t.text()}))])]}}))}))},e.prototype.getTextHints=function(){return a(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._hints()];case 1:return[2,e.apply(t,[n.sent().map((function(t){return t.text()}))])]}}))}))},e.prototype.getHarnessLoaderForPrefix=function(){return a(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._prefixContainer()]}))}))},e.prototype.getHarnessLoaderForSuffix=function(){return a(this,void 0,void 0,(function(){return s(this,(function(t){return[2,this._suffixContainer()]}))}))},e.prototype.isControlTouched=function(){return a(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._hasFormControl()];case 1:return t.sent()?[4,this.host()]:[2,null];case 2:return[2,t.sent().hasClass("ng-touched")]}}))}))},e.prototype.isControlDirty=function(){return a(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._hasFormControl()];case 1:return t.sent()?[4,this.host()]:[2,null];case 2:return[2,t.sent().hasClass("ng-dirty")]}}))}))},e.prototype.isControlValid=function(){return a(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._hasFormControl()];case 1:return t.sent()?[4,this.host()]:[2,null];case 2:return[2,t.sent().hasClass("ng-valid")]}}))}))},e.prototype.isControlPending=function(){return a(this,void 0,void 0,(function(){return s(this,(function(t){switch(t.label){case 0:return[4,this._hasFormControl()];case 1:return t.sent()?[4,this.host()]:[2,null];case 2:return[2,t.sent().hasClass("ng-pending")]}}))}))},e.prototype._hasFormControl=function(){return a(this,void 0,void 0,(function(){var t,e,n;return s(this,(function(r){switch(r.label){case 0:return[4,this.host()];case 1:return t=r.sent(),[4,Promise.all([t.hasClass("ng-touched"),t.hasClass("ng-untouched")])];case 2:return e=l.apply(void 0,[r.sent(),2]),n=e[1],[2,e[0]||n]}}))}))},e.hostSelector=".mat-form-field",e}(n.ComponentHarness); /** * @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 */Object.keys(e).forEach((function(n){"default"!==n&&Object.defineProperty(t,n,{enumerable:!0,get:function(){return e[n]}})})),t.MatFormFieldHarness=u,Object.defineProperty(t,"__esModule",{value:!0})}));