UNPKG

@angular/material

Version:
22 lines 5.36 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("tslib"),require("@angular/cdk/testing"),require("@angular/cdk/coercion")):"function"==typeof define&&define.amd?define("@angular/material/slider/testing",["exports","tslib","@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.tslib,t.ng.cdk.testing,t.ng.cdk.coercion)}(this,(function(t,e,r,n){"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 */var i=function(t){function i(){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 e.__extends(i,t),i.with=function(t){return void 0===t&&(t={}),new r.HarnessPredicate(i,t)},i.prototype.getId=function(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(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]}}))}))},i.prototype.getDisplayValue=function(){return e.__awaiter(this,void 0,void 0,(function(){var t,r;return e.__generator(this,(function(n){switch(n.label){case 0:return[4,Promise.all([this.host(),this._textLabel()])];case 1:return t=e.__read.apply(void 0,[n.sent(),2]),r=t[1],[4,t[0].hasClass("mat-slider-thumb-label-showing")];case 2:return n.sent()?[2,r.text()]:[2,null]}}))}))},i.prototype.getPercentage=function(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(this,(function(e){switch(e.label){case 0:return t=this._calculatePercentage,[4,this.getValue()];case 1:return[2,t.apply(this,[e.sent()])]}}))}))},i.prototype.getValue=function(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(this,(function(e){switch(e.label){case 0:return t=n.coerceNumberProperty,[4,this.host()];case 1:return[4,e.sent().getAttribute("aria-valuenow")];case 2:return[2,t.apply(void 0,[e.sent()])]}}))}))},i.prototype.getMaxValue=function(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(this,(function(e){switch(e.label){case 0:return t=n.coerceNumberProperty,[4,this.host()];case 1:return[4,e.sent().getAttribute("aria-valuemax")];case 2:return[2,t.apply(void 0,[e.sent()])]}}))}))},i.prototype.getMinValue=function(){return e.__awaiter(this,void 0,void 0,(function(){var t;return e.__generator(this,(function(e){switch(e.label){case 0:return t=n.coerceNumberProperty,[4,this.host()];case 1:return[4,e.sent().getAttribute("aria-valuemin")];case 2:return[2,t.apply(void 0,[e.sent()])]}}))}))},i.prototype.isDisabled=function(){return e.__awaiter(this,void 0,void 0,(function(){var t,r;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,this.host()];case 1:return t=e.sent().getAttribute("aria-disabled"),r=n.coerceBooleanProperty,[4,t];case 2:return[2,r.apply(void 0,[e.sent()])]}}))}))},i.prototype.getOrientation=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("aria-orientation")]}}))}))},i.prototype.setValue=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r,n,i,a,s,o,u,c,l,h,d;return e.__generator(this,(function(_){switch(_.label){case 0:return[4,Promise.all([this.host(),this._wrapper(),this.getOrientation()])];case 1:return r=e.__read.apply(void 0,[_.sent(),3]),n=r[0],i=r[1],a=r[2],[4,this._calculatePercentage(t)];case 2:return s=_.sent(),[4,i.getDimensions()];case 3:return o=_.sent(),u=o.height,c=o.width,l="vertical"===a,[4,n.hasClass("mat-slider-invert-mouse-coords")];case 4:return _.sent()&&(s=1-s),h=l?0:Math.round(c*s),d=l?Math.round(u*s):0,[4,i.click(h,d)];case 5:return _.sent(),[2]}}))}))},i.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()]}}))}))},i.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()]}}))}))},i.prototype._calculatePercentage=function(t){return e.__awaiter(this,void 0,void 0,(function(){var r,n;return e.__generator(this,(function(i){switch(i.label){case 0:return[4,Promise.all([this.getMinValue(),this.getMaxValue()])];case 1:return r=e.__read.apply(void 0,[i.sent(),2]),[2,(t-(n=r[0]))/(r[1]-n)]}}))}))},i.hostSelector="mat-slider",i}(r.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=i,Object.defineProperty(t,"__esModule",{value:!0})}));