Skip to content

Commit 322ca9f

Browse files
committed
fixup! fixup! test(material-experimental/mdc-slider): add directionality tests
1 parent 9e6c432 commit 322ca9f

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

src/material-experimental/mdc-slider/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ ng_test_library(
7979
"@npm//@angular/forms",
8080
"@npm//@angular/platform-browser",
8181
"@npm//@material/slider",
82+
"@npm//rxjs",
8283
],
8384
)
8485

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

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {BidiModule} from '@angular/cdk/bidi';
9+
import {BidiModule, Directionality} from '@angular/cdk/bidi';
1010
import {Platform} from '@angular/cdk/platform';
1111
import {
1212
dispatchMouseEvent,
1313
dispatchPointerEvent,
1414
dispatchTouchEvent,
1515
} from '@angular/cdk/testing/private';
16-
import {Component, QueryList, Type, ViewChild, ViewChildren} from '@angular/core';
16+
import {Component, Provider, QueryList, Type, ViewChild, ViewChildren} from '@angular/core';
1717
import {
1818
ComponentFixture,
1919
fakeAsync,
@@ -25,6 +25,7 @@ import {
2525
import {FormControl, FormsModule, ReactiveFormsModule} from '@angular/forms';
2626
import {By} from '@angular/platform-browser';
2727
import {Thumb} from '@material/slider';
28+
import {of} from 'rxjs';
2829
import {MatSliderModule} from './module';
2930
import {MatSlider, MatSliderThumb, MatSliderVisualThumb} from './slider';
3031

@@ -42,10 +43,14 @@ describe('MDC-based MatSlider' , () => {
4243
spyOn(Element.prototype, 'setPointerCapture');
4344
});
4445

45-
function createComponent<T>(component: Type<T>): ComponentFixture<T> {
46+
function createComponent<T>(
47+
component: Type<T>,
48+
providers: Provider[] = [],
49+
): ComponentFixture<T> {
4650
TestBed.configureTestingModule({
4751
imports: [FormsModule, MatSliderModule, ReactiveFormsModule, BidiModule],
4852
declarations: [component],
53+
providers: [...providers],
4954
}).compileComponents();
5055
return TestBed.createComponent<T>(component);
5156
}
@@ -1160,12 +1165,14 @@ describe('MDC-based MatSlider' , () => {
11601165
});
11611166

11621167
describe('slider with direction', () => {
1163-
let fixture: ComponentFixture<RTLSlider>;
11641168
let sliderInstance: MatSlider;
11651169
let inputInstance: MatSliderThumb;
11661170

11671171
beforeEach(waitForAsync(() => {
1168-
fixture = createComponent(RTLSlider);
1172+
const fixture = createComponent(StandardSlider, [{
1173+
provide: Directionality,
1174+
useValue: ({value: 'rtl', change: of()})
1175+
}]);
11691176
fixture.detectChanges();
11701177
const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider));
11711178
sliderInstance = sliderDebugElement.componentInstance;
@@ -1179,13 +1186,15 @@ describe('MDC-based MatSlider' , () => {
11791186
});
11801187

11811188
describe('range slider with direction', () => {
1182-
let fixture: ComponentFixture<RTLRangeSlider>;
11831189
let sliderInstance: MatSlider;
11841190
let startInputInstance: MatSliderThumb;
11851191
let endInputInstance: MatSliderThumb;
11861192

11871193
beforeEach(waitForAsync(() => {
1188-
fixture = createComponent(RTLRangeSlider);
1194+
const fixture = createComponent(StandardRangeSlider, [{
1195+
provide: Directionality,
1196+
useValue: ({value: 'rtl', change: of()})
1197+
}]);
11891198
fixture.detectChanges();
11901199
const sliderDebugElement = fixture.debugElement.query(By.directive(MatSlider));
11911200
sliderInstance = sliderDebugElement.componentInstance;

0 commit comments

Comments
 (0)