Skip to content

Commit 9939124

Browse files
devversionwagnermaciel
authored andcommitted
test: refactor MDC-based slider tests to work in Safari v13.1
* Updates the MDC-based slider tests to work in Safari v13.1 * Updates the MDC-based slider tests so that the measurements are guaranteed to be based on a 100px wide slider (seems like this is not always the case sometimes; resulting in flakiness). (cherry picked from commit a3a8490)
1 parent 2825a9b commit 9939124

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,12 @@ xdescribe('MDC-based MatSlider', () => {
424424
// pixel will be a tick.
425425
const ticksPerTrackPercentage = (tickInterval * step);
426426
// iOS evaluates the "background" expression for the ticks to the exact number,
427-
// Firefox, Edge, Safari evaluate to a percentage value, and Chrome evaluates to
428-
// a rounded five-digit decimal number.
427+
// Firefox, Edge, Safari 12.1 evaluate to a percentage value. Chrome evaluates to
428+
// a rounded five-digit decimal number and Safari 13.1 evaluates to a decimal
429+
// representing the percentage.
429430
const expectationRegex = new RegExp(
430-
`(${sizeOfTick}|${ticksPerTrackPercentage}%|${sizeOfTick.toFixed(5)})`);
431+
`(${sizeOfTick}|${ticksPerTrackPercentage}%|${sizeOfTick.toFixed(5)}|` +
432+
`${ticksPerTrackPercentage / 100})`);
431433
expect(ticksContainerElement.style.background)
432434
.toMatch(expectationRegex);
433435
});
@@ -1239,10 +1241,13 @@ function flushRequestAnimationFrame() {
12391241
tick(16);
12401242
}
12411243

1242-
// Disable animations and make the slider an even 100px, so that we get nice
1243-
// round values in tests.
1244+
// Disable animations and make the slider an even 100px, so that we get
1245+
// nice round values in tests.
12441246
const styles = `
1245-
.mat-mdc-slider { min-width: 100px !important; }
1247+
.mat-mdc-slider {
1248+
min-width: 100px !important;
1249+
width: 100px;
1250+
}
12461251
`;
12471252

12481253
@Component({

0 commit comments

Comments
 (0)