@@ -71,6 +71,7 @@ describe('MDC-based MatSlider' , () => {
71
71
expect ( inputInstance . value ) . toBe ( 0 ) ;
72
72
expect ( sliderInstance . min ) . toBe ( 0 ) ;
73
73
expect ( sliderInstance . max ) . toBe ( 100 ) ;
74
+ expect ( inputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '0' ) ;
74
75
} ) ;
75
76
76
77
it ( 'should update the value on mousedown' , ( ) => {
@@ -126,6 +127,8 @@ describe('MDC-based MatSlider' , () => {
126
127
expect ( endInputInstance . value ) . toBe ( 100 ) ;
127
128
expect ( sliderInstance . min ) . toBe ( 0 ) ;
128
129
expect ( sliderInstance . max ) . toBe ( 100 ) ;
130
+ expect ( startInputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '0' ) ;
131
+ expect ( endInputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '100' ) ;
129
132
} ) ;
130
133
131
134
it ( 'should update the start value on a slide' , ( ) => {
@@ -657,6 +660,7 @@ describe('MDC-based MatSlider' , () => {
657
660
describe ( 'slider with custom thumb label formatting' , ( ) => {
658
661
let fixture : ComponentFixture < DiscreteSliderWithDisplayWith > ;
659
662
let sliderInstance : MatSlider ;
663
+ let inputInstance : MatSliderThumb ;
660
664
let valueIndicatorTextElement : Element ;
661
665
662
666
beforeEach ( ( ) => {
@@ -667,6 +671,13 @@ describe('MDC-based MatSlider' , () => {
667
671
sliderInstance = sliderDebugElement . componentInstance ;
668
672
valueIndicatorTextElement =
669
673
sliderNativeElement . querySelector ( '.mdc-slider__value-indicator-text' ) ! ;
674
+ inputInstance = sliderInstance . _getInput ( Thumb . END ) ;
675
+ } ) ;
676
+
677
+ it ( 'should set the aria-valuetext attribute with the given `displayWith` function' , ( ) => {
678
+ expect ( inputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '$1' ) ;
679
+ sliderInstance . _setValue ( 10000 , Thumb . END ) ;
680
+ expect ( inputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '$10k' ) ;
670
681
} ) ;
671
682
672
683
it ( 'should invoke the passed-in `displayWith` function with the value' , ( ) => {
@@ -687,12 +698,16 @@ describe('MDC-based MatSlider' , () => {
687
698
let sliderInstance : MatSlider ;
688
699
let startValueIndicatorTextElement : Element ;
689
700
let endValueIndicatorTextElement : Element ;
701
+ let startInputInstance : MatSliderThumb ;
702
+ let endInputInstance : MatSliderThumb ;
690
703
691
704
beforeEach ( ( ) => {
692
705
fixture = createComponent ( DiscreteRangeSliderWithDisplayWith ) ;
693
706
fixture . detectChanges ( ) ;
694
707
const sliderDebugElement = fixture . debugElement . query ( By . directive ( MatSlider ) ) ! ;
695
708
sliderInstance = sliderDebugElement . componentInstance ;
709
+ startInputInstance = sliderInstance . _getInput ( Thumb . START ) ;
710
+ endInputInstance = sliderInstance . _getInput ( Thumb . END ) ;
696
711
697
712
const startThumbElement = sliderInstance . _getThumbElement ( Thumb . START ) ;
698
713
const endThumbElement = sliderInstance . _getThumbElement ( Thumb . END ) ;
@@ -702,6 +717,15 @@ describe('MDC-based MatSlider' , () => {
702
717
endThumbElement . querySelector ( '.mdc-slider__value-indicator-text' ) ! ;
703
718
} ) ;
704
719
720
+ it ( 'should set the aria-valuetext attribute with the given `displayWith` function' , ( ) => {
721
+ expect ( startInputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '$1' ) ;
722
+ expect ( endInputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '$1000k' ) ;
723
+ sliderInstance . _setValue ( 250000 , Thumb . START ) ;
724
+ sliderInstance . _setValue ( 810000 , Thumb . END ) ;
725
+ expect ( startInputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '$250k' ) ;
726
+ expect ( endInputInstance . _hostElement . getAttribute ( 'aria-valuetext' ) ) . toBe ( '$810k' ) ;
727
+ } ) ;
728
+
705
729
it ( 'should invoke the passed-in `displayWith` function with the start value' , ( ) => {
706
730
spyOn ( sliderInstance , 'displayWith' ) . and . callThrough ( ) ;
707
731
sliderInstance . _setValue ( 1337 , Thumb . START ) ;
0 commit comments