@@ -1119,9 +1119,11 @@ describe('MatSlider', () => {
1119
1119
describe ( 'slider with direction' , ( ) => {
1120
1120
let slider : MatSlider ;
1121
1121
let input : MatSliderThumb ;
1122
+ let sliderEl : HTMLElement ;
1123
+ let fixture : ComponentFixture < StandardRangeSlider > ;
1122
1124
1123
1125
beforeEach ( waitForAsync ( ( ) => {
1124
- const fixture = createComponent ( StandardSlider , [
1126
+ fixture = createComponent ( StandardSlider , [
1125
1127
{
1126
1128
provide : Directionality ,
1127
1129
useValue : { value : 'rtl' , change : of ( ) } ,
@@ -1130,13 +1132,31 @@ describe('MatSlider', () => {
1130
1132
fixture . detectChanges ( ) ;
1131
1133
const sliderDebugElement = fixture . debugElement . query ( By . directive ( MatSlider ) ) ;
1132
1134
slider = sliderDebugElement . componentInstance ;
1135
+ sliderEl = sliderDebugElement . nativeElement ;
1133
1136
input = slider . _getInput ( _MatThumb . END ) as MatSliderThumb ;
1134
1137
} ) ) ;
1135
1138
1136
1139
it ( 'works in RTL languages' , fakeAsync ( ( ) => {
1137
1140
setValueByClick ( slider , input , 25 , true ) ;
1138
1141
checkInput ( input , { min : 0 , max : 100 , value : 75 , translateX : 75 } ) ;
1139
1142
} ) ) ;
1143
+
1144
+ it ( 'should position the tick marks correctly with a misaligned step (rtl)' , ( ) => {
1145
+ slider . showTickMarks = true ;
1146
+ slider . min = 0 ;
1147
+ slider . max = 10 ;
1148
+ slider . step = 9 ;
1149
+
1150
+ fixture . detectChanges ( ) ;
1151
+
1152
+ const activeClass = '.mdc-slider__tick-mark--active' ;
1153
+ const inactiveClass = '.mdc-slider__tick-mark--inactive' ;
1154
+ const ticks = sliderEl . querySelectorAll ( `${ activeClass } ,${ inactiveClass } ` ) ;
1155
+
1156
+ expect ( ticks . length ) . toBe ( 2 ) ;
1157
+ expect ( ticks [ 0 ] . getBoundingClientRect ( ) . x ) . toBe ( 312 ) ;
1158
+ expect ( ticks [ 1 ] . getBoundingClientRect ( ) . x ) . toBeCloseTo ( 47.4 , 2 ) ;
1159
+ } ) ;
1140
1160
} ) ;
1141
1161
1142
1162
describe ( 'range slider with direction' , ( ) => {
@@ -1622,11 +1642,17 @@ describe('MatSlider', () => {
1622
1642
expect ( tickEls . inactive . length ) . toBe ( 0 ) ;
1623
1643
} ) ;
1624
1644
1625
- // TODO(wagnermaciel): Add this test once this is fixed.
1626
- // it('should position the tick marks correctly with a misaligned step', () => {});
1645
+ it ( 'should position the tick marks correctly with a misaligned step' , ( ) => {
1646
+ slider . max = 10 ;
1647
+ slider . step = 9 ;
1648
+ fixture . detectChanges ( ) ;
1649
+
1650
+ const { ticks} = getTickMarkEls ( ) ;
1651
+ expect ( ticks . length ) . toBe ( 2 ) ;
1627
1652
1628
- // TODO(wagnermaciel): Add this test once this is fixed.
1629
- // it('should position the tick marks correctly with a misaligned step (rtl)', () => {});
1653
+ expect ( ticks [ 0 ] . getBoundingClientRect ( ) . x ) . toBe ( 18 ) ;
1654
+ expect ( ticks [ 1 ] . getBoundingClientRect ( ) . x ) . toBeCloseTo ( 282.6 , 2 ) ;
1655
+ } ) ;
1630
1656
} ) ;
1631
1657
1632
1658
describe ( 'range slider with tick marks' , ( ) => {
0 commit comments