@@ -12,6 +12,7 @@ import {HarnessLoader, parallel} from '@angular/cdk/testing';
12
12
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed' ;
13
13
import { MatSliderModule } from '@angular/material-experimental/mdc-slider' ;
14
14
import { MatSliderHarness } from './slider-harness' ;
15
+ import { MatSliderThumbHarness } from './slider-thumb-harness' ;
15
16
import { ThumbPosition } from './slider-harness-filters' ;
16
17
17
18
describe ( 'MDC-based MatSliderHarness' , ( ) => {
@@ -62,7 +63,7 @@ describe('MDC-based MatSliderHarness', () => {
62
63
63
64
it ( 'should get the thumbs within a slider' , async ( ) => {
64
65
const sliders = await loader . getAllHarnesses ( MatSliderHarness ) ;
65
- expect ( await sliders [ 0 ] . getStartThumb ( ) ) . toBeTruthy ( ) ;
66
+ expect ( await sliders [ 0 ] . getEndThumb ( ) ) . toBeTruthy ( ) ;
66
67
expect ( await sliders [ 1 ] . getStartThumb ( ) ) . toBeTruthy ( ) ;
67
68
expect ( await sliders [ 1 ] . getEndThumb ( ) ) . toBeTruthy ( ) ;
68
69
} ) ;
@@ -74,24 +75,29 @@ describe('MDC-based MatSliderHarness', () => {
74
75
} ) ) . toEqual ( [ 1 , fixture . componentInstance . rangeSliderStep ] ) ;
75
76
} ) ;
76
77
77
- it ( 'should get the position of a slider thumb' , async ( ) => {
78
+ it ( 'should get the position of a slider thumb in a range slider ' , async ( ) => {
78
79
const slider = await loader . getHarness ( MatSliderHarness . with ( { selector : '#range' } ) ) ;
79
80
const [ start , end ] = await parallel ( ( ) => [ slider . getStartThumb ( ) , slider . getEndThumb ( ) ] ) ;
80
81
expect ( await start . getPosition ( ) ) . toBe ( ThumbPosition . START ) ;
81
82
expect ( await end . getPosition ( ) ) . toBe ( ThumbPosition . END ) ;
82
83
} ) ;
83
84
85
+ it ( 'should get the position of a slider thumb in a non-range slider' , async ( ) => {
86
+ const thumb = await loader . getHarness ( MatSliderThumbHarness . with ( { ancestor : '#single' } ) ) ;
87
+ expect ( await thumb . getPosition ( ) ) . toBe ( ThumbPosition . END ) ;
88
+ } ) ;
89
+
84
90
it ( 'should get and set the value of a slider thumb' , async ( ) => {
85
91
const slider = await loader . getHarness ( MatSliderHarness ) ;
86
- const thumb = await slider . getStartThumb ( ) ;
92
+ const thumb = await slider . getEndThumb ( ) ;
87
93
expect ( await thumb . getValue ( ) ) . toBe ( 0 ) ;
88
94
await thumb . setValue ( 73 ) ;
89
95
expect ( await thumb . getValue ( ) ) . toBe ( 73 ) ;
90
96
} ) ;
91
97
92
98
it ( 'should dispatch input and change events when setting the value' , async ( ) => {
93
99
const slider = await loader . getHarness ( MatSliderHarness ) ;
94
- const thumb = await slider . getStartThumb ( ) ;
100
+ const thumb = await slider . getEndThumb ( ) ;
95
101
const changeSpy = spyOn ( fixture . componentInstance , 'changeListener' ) ;
96
102
const inputSpy = spyOn ( fixture . componentInstance , 'inputListener' ) ;
97
103
await thumb . setValue ( 73 ) ;
@@ -102,14 +108,14 @@ describe('MDC-based MatSliderHarness', () => {
102
108
103
109
it ( 'should get the value of a thumb as a percentage' , async ( ) => {
104
110
const sliders = await loader . getAllHarnesses ( MatSliderHarness ) ;
105
- expect ( await ( await sliders [ 0 ] . getStartThumb ( ) ) . getPercentage ( ) ) . toBe ( 0 ) ;
111
+ expect ( await ( await sliders [ 0 ] . getEndThumb ( ) ) . getPercentage ( ) ) . toBe ( 0 ) ;
106
112
expect ( await ( await sliders [ 1 ] . getStartThumb ( ) ) . getPercentage ( ) ) . toBe ( 0.4 ) ;
107
113
expect ( await ( await sliders [ 1 ] . getEndThumb ( ) ) . getPercentage ( ) ) . toBe ( 0.5 ) ;
108
114
} ) ;
109
115
110
116
it ( 'should get the display value of a slider thumb' , async ( ) => {
111
117
const slider = await loader . getHarness ( MatSliderHarness ) ;
112
- const thumb = await slider . getStartThumb ( ) ;
118
+ const thumb = await slider . getEndThumb ( ) ;
113
119
fixture . componentInstance . displayFn = value => `#${ value } ` ;
114
120
await thumb . setValue ( 73 ) ;
115
121
expect ( await thumb . getDisplayValue ( ) ) . toBe ( '#73' ) ;
@@ -128,7 +134,7 @@ describe('MDC-based MatSliderHarness', () => {
128
134
129
135
it ( 'should get the disabled state of a slider thumb' , async ( ) => {
130
136
const slider = await loader . getHarness ( MatSliderHarness ) ;
131
- const thumb = await slider . getStartThumb ( ) ;
137
+ const thumb = await slider . getEndThumb ( ) ;
132
138
133
139
expect ( await thumb . isDisabled ( ) ) . toBe ( false ) ;
134
140
fixture . componentInstance . singleSliderDisabled = true ;
@@ -137,17 +143,17 @@ describe('MDC-based MatSliderHarness', () => {
137
143
138
144
it ( 'should get the name of a slider thumb' , async ( ) => {
139
145
const slider = await loader . getHarness ( MatSliderHarness ) ;
140
- expect ( await ( await slider . getStartThumb ( ) ) . getName ( ) ) . toBe ( 'price' ) ;
146
+ expect ( await ( await slider . getEndThumb ( ) ) . getName ( ) ) . toBe ( 'price' ) ;
141
147
} ) ;
142
148
143
149
it ( 'should get the id of a slider thumb' , async ( ) => {
144
150
const slider = await loader . getHarness ( MatSliderHarness ) ;
145
- expect ( await ( await slider . getStartThumb ( ) ) . getId ( ) ) . toBe ( 'price-input' ) ;
151
+ expect ( await ( await slider . getEndThumb ( ) ) . getId ( ) ) . toBe ( 'price-input' ) ;
146
152
} ) ;
147
153
148
154
it ( 'should be able to focus and blur a slider thumb' , async ( ) => {
149
155
const slider = await loader . getHarness ( MatSliderHarness ) ;
150
- const thumb = await slider . getStartThumb ( ) ;
156
+ const thumb = await slider . getEndThumb ( ) ;
151
157
152
158
expect ( await thumb . isFocused ( ) ) . toBe ( false ) ;
153
159
await thumb . focus ( ) ;
0 commit comments