Skip to content

Commit d0566e9

Browse files
committed
fix(material-experimental/mdc-slider): avoid using whenStable (#22571)
* whenStable was causing tests to pass even when they should have been failing
1 parent e73c943 commit d0566e9

File tree

1 file changed

+12
-21
lines changed

1 file changed

+12
-21
lines changed

src/material-experimental/mdc-slider/slider.spec.ts

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -657,18 +657,15 @@ describe('MDC-based MatSlider' , () => {
657657
});
658658

659659
it('should invoke the passed-in `displayWith` function with the value', () => {
660-
spyOn(fixture.componentInstance, 'displayWith').and.callThrough();
660+
spyOn(sliderInstance, 'displayWith').and.callThrough();
661661
sliderInstance._setValue(1337, Thumb.END);
662-
fixture.whenStable().then(() => {
663-
expect(fixture.componentInstance.displayWith).toHaveBeenCalledWith(1337);
664-
});
662+
expect(sliderInstance.displayWith).toHaveBeenCalledWith(1337);
665663
});
666664

667665
it('should format the thumb label based on the passed-in `displayWith` function', () => {
668666
sliderInstance._setValue(200000, Thumb.END);
669-
fixture.whenStable().then(() => {
670-
expect(valueIndicatorTextElement.textContent).toBe('200k');
671-
});
667+
fixture.detectChanges();
668+
expect(valueIndicatorTextElement.textContent).toBe('$200k');
672669
});
673670
});
674671

@@ -693,33 +690,27 @@ describe('MDC-based MatSlider' , () => {
693690
});
694691

695692
it('should invoke the passed-in `displayWith` function with the start value', () => {
696-
spyOn(fixture.componentInstance, 'displayWith').and.callThrough();
693+
spyOn(sliderInstance, 'displayWith').and.callThrough();
697694
sliderInstance._setValue(1337, Thumb.START);
698-
fixture.whenStable().then(() => {
699-
expect(fixture.componentInstance.displayWith).toHaveBeenCalledWith(1337);
700-
});
695+
expect(sliderInstance.displayWith).toHaveBeenCalledWith(1337);
701696
});
702697

703698
it('should invoke the passed-in `displayWith` function with the end value', () => {
704-
spyOn(fixture.componentInstance, 'displayWith').and.callThrough();
699+
spyOn(sliderInstance, 'displayWith').and.callThrough();
705700
sliderInstance._setValue(5996, Thumb.END);
706-
fixture.whenStable().then(() => {
707-
expect(fixture.componentInstance.displayWith).toHaveBeenCalledWith(5996);
708-
});
701+
expect(sliderInstance.displayWith).toHaveBeenCalledWith(5996);
709702
});
710703

711704
it('should format the start thumb label based on the passed-in `displayWith` function', () => {
712705
sliderInstance._setValue(200000, Thumb.START);
713-
fixture.whenStable().then(() => {
714-
expect(startValueIndicatorTextElement.textContent).toBe('200k');
715-
});
706+
fixture.detectChanges();
707+
expect(startValueIndicatorTextElement.textContent).toBe('$200k');
716708
});
717709

718710
it('should format the end thumb label based on the passed-in `displayWith` function', () => {
719711
sliderInstance._setValue(700000, Thumb.END);
720-
fixture.whenStable().then(() => {
721-
expect(endValueIndicatorTextElement.textContent).toBe('700k');
722-
});
712+
fixture.detectChanges();
713+
expect(endValueIndicatorTextElement.textContent).toBe('$700k');
723714
});
724715
});
725716

0 commit comments

Comments
 (0)