Skip to content

fix(material-experimental/mdc-slider): avoid using whenStable #22571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 12 additions & 21 deletions src/material-experimental/mdc-slider/slider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,18 +657,15 @@ describe('MDC-based MatSlider' , () => {
});

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

it('should format the thumb label based on the passed-in `displayWith` function', () => {
sliderInstance._setValue(200000, Thumb.END);
fixture.whenStable().then(() => {
expect(valueIndicatorTextElement.textContent).toBe('200k');
});
fixture.detectChanges();
expect(valueIndicatorTextElement.textContent).toBe('$200k');
});
});

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

it('should invoke the passed-in `displayWith` function with the start value', () => {
spyOn(fixture.componentInstance, 'displayWith').and.callThrough();
spyOn(sliderInstance, 'displayWith').and.callThrough();
sliderInstance._setValue(1337, Thumb.START);
fixture.whenStable().then(() => {
expect(fixture.componentInstance.displayWith).toHaveBeenCalledWith(1337);
});
expect(sliderInstance.displayWith).toHaveBeenCalledWith(1337);
});

it('should invoke the passed-in `displayWith` function with the end value', () => {
spyOn(fixture.componentInstance, 'displayWith').and.callThrough();
spyOn(sliderInstance, 'displayWith').and.callThrough();
sliderInstance._setValue(5996, Thumb.END);
fixture.whenStable().then(() => {
expect(fixture.componentInstance.displayWith).toHaveBeenCalledWith(5996);
});
expect(sliderInstance.displayWith).toHaveBeenCalledWith(5996);
});

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

it('should format the end thumb label based on the passed-in `displayWith` function', () => {
sliderInstance._setValue(700000, Thumb.END);
fixture.whenStable().then(() => {
expect(endValueIndicatorTextElement.textContent).toBe('700k');
});
fixture.detectChanges();
expect(endValueIndicatorTextElement.textContent).toBe('$700k');
});
});

Expand Down