Skip to content

Commit c4dade2

Browse files
authored
Merge pull request #7985 from IgniteUI/slider-ticks-tests
test(slider): add aditional test for slider ticks
2 parents 4966d67 + c7a9faf commit c4dade2

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

projects/igniteui-angular/src/lib/slider/slider.component.spec.ts

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const THUMB_TO_CLASS = '.igx-slider__thumb-to';
1515
const THUMB_FROM_CLASS = '.igx-slider__thumb-from';
1616
const SLIDER_TICKS_ELEMENT = '.igx-slider__ticks';
1717
const SLIDER_TICKS_TOP_ELEMENT = '.igx-slider__ticks--top';
18-
const SLIDER_PRIMARY_GROUP_TICKS_CLASS = '.igx-slider__ticks-group--tall';
1918
const SLIDER_PRIMARY_GROUP_TICKS_CLASS_NAME = 'igx-slider__ticks-group--tall';
19+
const SLIDER_PRIMARY_GROUP_TICKS_CLASS = `.${SLIDER_PRIMARY_GROUP_TICKS_CLASS_NAME}`;
2020
const SLIDER_GROUP_TICKS_CLASS = '.igx-slider__ticks-group';
2121
const SLIDER_TICK_LABELS_CLASS = '.igx-slider__ticks-label';
2222
const SLIDER_TICK_LABELS_HIDDEN_CLASS = 'igx-slider__tick-label--hidden';
@@ -1427,6 +1427,24 @@ describe('IgxSlider', () => {
14271427
expect(secondaryTicks.length).toEqual((expectedPrimary - 1) * expectedSecondary);
14281428
});
14291429

1430+
it('check primary ticks length (16px)', () => {
1431+
const ticks = fixture.debugElement.query(By.css(SLIDER_TICKS_ELEMENT));
1432+
fixture.componentInstance.primaryTicks = 5;
1433+
fixture.detectChanges();
1434+
1435+
const primaryTick = ticks.nativeElement.querySelectorAll(SLIDER_PRIMARY_GROUP_TICKS_CLASS)[0];
1436+
expect(primaryTick.firstElementChild.getBoundingClientRect().height).toEqual(16);
1437+
});
1438+
1439+
it('check secondary ticks length (8px)', () => {
1440+
const ticks = fixture.debugElement.query(By.css(SLIDER_TICKS_ELEMENT));
1441+
fixture.componentInstance.secondaryTicks = 5;
1442+
fixture.detectChanges();
1443+
1444+
const primaryTick = ticks.nativeElement.querySelectorAll(SLIDER_GROUP_TICKS_CLASS)[0];
1445+
expect(primaryTick.firstElementChild.getBoundingClientRect().height).toEqual(8);
1446+
});
1447+
14301448
it('hide/show top and bottom ticks', () => {
14311449
let ticks = fixture.debugElement.nativeElement.querySelector(SLIDER_TICKS_ELEMENT);
14321450
let ticksTop = fixture.debugElement.nativeElement.querySelector(SLIDER_TICKS_TOP_ELEMENT);
@@ -1485,6 +1503,7 @@ describe('IgxSlider', () => {
14851503
verifySecondaryTicsLabelsAreHidden(ticks, false);
14861504
});
14871505

1506+
14881507
it('show/hide secondary tick labels', () => {
14891508
const ticks = fixture.debugElement.query(By.css(SLIDER_TICKS_ELEMENT));
14901509
const primaryTicks = 5;
@@ -1559,6 +1578,25 @@ describe('IgxSlider', () => {
15591578
expect(labelsTopBottom).not.toBeNull();
15601579
expect(labelsBottomTop).toBeNull();
15611580
});
1581+
1582+
it('ticks change should reflect dynamically when slider labels are changed', () => {
1583+
const ticks = fixture.debugElement.query(By.css(SLIDER_TICKS_ELEMENT));
1584+
let labels = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
1585+
slider.labels = labels;
1586+
fixture.detectChanges();
1587+
1588+
let primaryTicks = ticks.nativeElement.querySelectorAll(SLIDER_PRIMARY_GROUP_TICKS_CLASS);
1589+
expect(primaryTicks.length).toEqual(labels.length);
1590+
1591+
labels = labels.splice(0, labels.length - 2);
1592+
slider.labels = labels;
1593+
fixture.detectChanges();
1594+
1595+
primaryTicks = ticks.nativeElement.querySelectorAll(SLIDER_PRIMARY_GROUP_TICKS_CLASS);
1596+
1597+
expect(primaryTicks.length).toEqual(labels.length);
1598+
1599+
});
15621600
});
15631601

15641602
describe('EditorProvider', () => {
@@ -1677,7 +1715,8 @@ export class SliderRtlComponent {
16771715
`
16781716
})
16791717
export class SliderTicksComponent {
1680-
@ViewChild(IgxSliderComponent)
1718+
1719+
@ViewChild(IgxSliderComponent, {static: true})
16811720
public slider: IgxSliderComponent;
16821721

16831722
public primaryTicks = 0;

0 commit comments

Comments
 (0)