UNPKG

@angular/material

Version:
37 lines (35 loc) 7.81 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/testing"),require("@angular/cdk/coercion")):"function"==typeof define&&define.amd?define("@angular/material/slider/testing",["exports","@angular/cdk/testing","@angular/cdk/coercion"],e):e(((t=t||self).ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.slider=t.ng.material.slider||{},t.ng.material.slider.testing={}),t.ng.cdk.testing,t.ng.cdk.coercion)}(this,(function(t,e,r){"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 n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function i(t,e,r,n){return new(r||(r=Promise))((function(i,o){function a(t){try{s(n.next(t))}catch(t){o(t)}}function u(t){try{s(n.throw(t))}catch(t){o(t)}}function s(t){t.done?i(t.value):new r((function(e){e(t.value)})).then(a,u)}s((n=n.apply(t,e||[])).next())}))}function o(t,e){var r,n,i,o,a={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 s(o){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],n=0}finally{r=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)a.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.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 u(){var e=null!==t&&t.apply(this,arguments)||this;return e._textLabel=e.locatorFor(".mat-slider-thumb-label-text"),e._wrapper=e.locatorFor(".mat-slider-wrapper"),e}return function s(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}(u,t),u.with=function(t){return void 0===t&&(t={}),new e.HarnessPredicate(u,t)},u.prototype.getId=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this.host()];case 1:return[4,e.sent().getAttribute("id")];case 2:return[2,""!==(t=e.sent())?t:null]}}))}))},u.prototype.getDisplayValue=function(){return i(this,void 0,void 0,(function(){var t,e;return o(this,(function(r){switch(r.label){case 0:return[4,Promise.all([this.host(),this._textLabel()])];case 1:return t=a.apply(void 0,[r.sent(),2]),e=t[1],[4,t[0].hasClass("mat-slider-thumb-label-showing")];case 2:return r.sent()?[2,e.text()]:[2,null]}}))}))},u.prototype.getPercentage=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t=this._calculatePercentage,[4,this.getValue()];case 1:return[2,t.apply(this,[e.sent()])]}}))}))},u.prototype.getValue=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t=r.coerceNumberProperty,[4,this.host()];case 1:return[4,e.sent().getAttribute("aria-valuenow")];case 2:return[2,t.apply(void 0,[e.sent()])]}}))}))},u.prototype.getMaxValue=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t=r.coerceNumberProperty,[4,this.host()];case 1:return[4,e.sent().getAttribute("aria-valuemax")];case 2:return[2,t.apply(void 0,[e.sent()])]}}))}))},u.prototype.getMinValue=function(){return i(this,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return t=r.coerceNumberProperty,[4,this.host()];case 1:return[4,e.sent().getAttribute("aria-valuemin")];case 2:return[2,t.apply(void 0,[e.sent()])]}}))}))},u.prototype.isDisabled=function(){return i(this,void 0,void 0,(function(){var t,e;return o(this,(function(n){switch(n.label){case 0:return[4,this.host()];case 1:return t=n.sent().getAttribute("aria-disabled"),e=r.coerceBooleanProperty,[4,t];case 2:return[2,e.apply(void 0,[n.sent()])]}}))}))},u.prototype.getOrientation=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().getAttribute("aria-orientation")]}}))}))},u.prototype.setValue=function(t){return i(this,void 0,void 0,(function(){var e,r,n,i,u,s,c,l,h,f,p;return o(this,(function(o){switch(o.label){case 0:return[4,Promise.all([this.host(),this._wrapper(),this.getOrientation()])];case 1:return e=a.apply(void 0,[o.sent(),3]),r=e[0],n=e[1],i=e[2],[4,this._calculatePercentage(t)];case 2:return u=o.sent(),[4,n.getDimensions()];case 3:return s=o.sent(),c=s.height,l=s.width,h="vertical"===i,[4,r.hasClass("mat-slider-invert-mouse-coords")];case 4:return o.sent()&&(u=1-u),f=h?0:Math.round(l*u),p=h?Math.round(c*u):0,[4,n.click(f,p)];case 5:return o.sent(),[2]}}))}))},u.prototype.focus=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().focus()]}}))}))},u.prototype.blur=function(){return i(this,void 0,void 0,(function(){return o(this,(function(t){switch(t.label){case 0:return[4,this.host()];case 1:return[2,t.sent().blur()]}}))}))},u.prototype._calculatePercentage=function(t){return i(this,void 0,void 0,(function(){var e,r;return o(this,(function(n){switch(n.label){case 0:return[4,Promise.all([this.getMinValue(),this.getMaxValue()])];case 1:return e=a.apply(void 0,[n.sent(),2]),[2,(t-(r=e[0]))/(e[1]-r)]}}))}))},u.hostSelector="mat-slider",u}(e.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 */t.MatSliderHarness=u,Object.defineProperty(t,"__esModule",{value:!0})}));