Skip to content

Commit 6253b1c

Browse files
committed
test(stepper): revert unit and e2e tests
1 parent bda6e47 commit 6253b1c

File tree

2 files changed

+27
-75
lines changed

2 files changed

+27
-75
lines changed

e2e/components/stepper-e2e.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ describe('stepper', () => {
1818
const nextButton = element.all(by.buttonText('Next'));
1919

2020
expect(await element(by.css('mat-step-header[aria-selected="true"]')).getText())
21-
.toBe('create\nFill out your name');
21+
.toBe('1\nFill out your name');
2222

2323
nextButton.get(0).click();
2424

2525
expect(await element(by.css('mat-step-header[aria-selected="true"]')).getText())
26-
.toBe('create\nFill out your address');
26+
.toBe('2\nFill out your address');
2727

2828
await browser.wait(ExpectedConditions.not(
2929
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
3030

3131
previousButton.get(0).click();
3232

3333
expect(await element(by.css('mat-step-header[aria-selected="true"]')).getText())
34-
.toBe('create\nFill out your name');
34+
.toBe('1\nFill out your name');
3535

3636
await browser.wait(ExpectedConditions.not(
3737
ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element')))));
@@ -73,7 +73,7 @@ describe('stepper', () => {
7373
nextButton.get(0).click();
7474

7575
expect(await element(by.css('mat-step-header[aria-selected="true"]')).getText())
76-
.toBe('create\nFill out your name');
76+
.toBe('1\nFill out your name');
7777
});
7878
});
7979
});

src/lib/stepper/stepper.spec.ts

Lines changed: 23 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
SPACE,
1010
UP_ARROW,
1111
} from '@angular/cdk/keycodes';
12-
import {StepperOrientation, STEP_STATE} from '@angular/cdk/stepper';
12+
import {StepperOrientation} from '@angular/cdk/stepper';
1313
import {dispatchKeyboardEvent} from '@angular/cdk/testing';
1414
import {Component, DebugElement, EventEmitter, OnInit} from '@angular/core';
1515
import {async, ComponentFixture, fakeAsync, flush, inject, TestBed} from '@angular/core/testing';
@@ -292,62 +292,28 @@ describe('MatStepper', () => {
292292
expect(stepperComponent.selectedIndex).toBe(0);
293293
});
294294

295-
describe('with custom state', () => {
296-
it('should set the custom icon when the step is completed and on selected step', () => {
297-
let stepperComponent = fixture.debugElement
298-
.query(By.directive(MatStepper)).componentInstance;
299-
const firstStep = stepperComponent._steps.toArray()[0];
300-
301-
expect(stepperComponent._getIndicatorType(0, 'warning')).toBe(STEP_STATE.EDIT);
302-
303-
stepperComponent.selectedIndex = 0;
304-
firstStep.completed = true;
305-
fixture.detectChanges();
306-
307-
expect(stepperComponent._getIndicatorType(0, 'warning')).toBe('warning');
308-
});
309-
});
310-
311-
it('should set error icon if step has error', () => {
295+
it('should set create icon if step is editable and completed', () => {
312296
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
313297
let nextButtonNativeEl = fixture.debugElement
314298
.queryAll(By.directive(MatStepperNext))[0].nativeElement;
315-
const firstStep = stepperComponent._steps.toArray()[0];
316-
317-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.EDIT);
318-
319-
firstStep.hasError = true;
299+
expect(stepperComponent._getIndicatorType(0)).toBe('number');
300+
stepperComponent._steps.toArray()[0].editable = true;
320301
nextButtonNativeEl.click();
321302
fixture.detectChanges();
322303

323-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.ERROR);
304+
expect(stepperComponent._getIndicatorType(0)).toBe('edit');
324305
});
325306

326-
it('should set done icon if step is completed', () => {
307+
it('should set done icon if step is not editable and is completed', () => {
327308
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
328309
let nextButtonNativeEl = fixture.debugElement
329310
.queryAll(By.directive(MatStepperNext))[0].nativeElement;
330-
const firstStep = stepperComponent._steps.toArray()[0];
331-
332-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.EDIT);
333-
334-
firstStep.completed = true;
311+
expect(stepperComponent._getIndicatorType(0)).toBe('number');
312+
stepperComponent._steps.toArray()[0].editable = false;
335313
nextButtonNativeEl.click();
336314
fixture.detectChanges();
337315

338-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.DONE);
339-
});
340-
341-
it('should set number icon if step is completed and on selected step', () => {
342-
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
343-
const firstStep = stepperComponent._steps.toArray()[0];
344-
345-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.EDIT);
346-
347-
firstStep.completed = true;
348-
fixture.detectChanges();
349-
350-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.NUMBER);
316+
expect(stepperComponent._getIndicatorType(0)).toBe('done');
351317
});
352318

353319
it('should re-render when the i18n labels change', inject([MatStepperIntl],
@@ -432,23 +398,12 @@ describe('MatStepper', () => {
432398
fixture.detectChanges();
433399
});
434400

435-
it('should override any icon', () => {
436-
const stepperDebugElement = fixture.debugElement.query(By.directive(MatStepper));
437-
const stepperComponent: MatStepper = stepperDebugElement.componentInstance;
438-
439-
stepperComponent._steps.toArray()[3].completed = true;
440-
fixture.detectChanges();
441-
442-
const headers = stepperDebugElement.nativeElement.querySelectorAll('mat-step-header');
443-
444-
expect(headers[3].textContent).toContain('Custom warning');
445-
});
446-
447401
it('should allow for the `edit` icon to be overridden', () => {
448402
const stepperDebugElement = fixture.debugElement.query(By.directive(MatStepper));
449403
const stepperComponent: MatStepper = stepperDebugElement.componentInstance;
450404

451405
stepperComponent._steps.toArray()[0].editable = true;
406+
stepperComponent.next();
452407
fixture.detectChanges();
453408

454409
const header = stepperDebugElement.nativeElement.querySelector('mat-step-header');
@@ -745,13 +700,12 @@ describe('MatStepper', () => {
745700

746701
const stepper: MatHorizontalStepper = noStepControlFixture.debugElement
747702
.query(By.directive(MatHorizontalStepper)).componentInstance;
748-
const firstStep = stepper._steps.toArray()[0];
703+
749704
const headers = noStepControlFixture.debugElement
750705
.queryAll(By.css('.mat-horizontal-stepper-header'));
751706

752707
expect(stepper.selectedIndex).toBe(0);
753708

754-
firstStep.completed = false;
755709
headers[1].nativeElement.click();
756710
noStepControlFixture.detectChanges();
757711

@@ -768,16 +722,16 @@ describe('MatStepper', () => {
768722
controlAndBindingFixture.detectChanges();
769723

770724
expect(controlAndBindingFixture.componentInstance.steps[0].control.valid).toBe(true);
725+
expect(controlAndBindingFixture.componentInstance.steps[0].completed).toBe(false);
771726

772727
const stepper: MatHorizontalStepper = controlAndBindingFixture.debugElement
773728
.query(By.directive(MatHorizontalStepper)).componentInstance;
774-
const firstStep = stepper._steps.toArray()[0];
729+
775730
const headers = controlAndBindingFixture.debugElement
776731
.queryAll(By.css('.mat-horizontal-stepper-header'));
777732

778733
expect(stepper.selectedIndex).toBe(0);
779734

780-
firstStep.completed = false;
781735
headers[1].nativeElement.click();
782736
controlAndBindingFixture.detectChanges();
783737

@@ -1183,16 +1137,16 @@ class SimplePreselectedMatHorizontalStepperApp {
11831137
<mat-horizontal-stepper linear>
11841138
<mat-step
11851139
*ngFor="let step of steps"
1186-
[label]="step.label">
1187-
</mat-step>
1140+
[label]="step.label"
1141+
[completed]="step.completed"></mat-step>
11881142
</mat-horizontal-stepper>
11891143
`
11901144
})
11911145
class SimpleStepperWithoutStepControl {
11921146
steps = [
1193-
{label: 'One'},
1194-
{label: 'Two'},
1195-
{label: 'Three'}
1147+
{label: 'One', completed: false},
1148+
{label: 'Two', completed: false},
1149+
{label: 'Three', completed: false}
11961150
];
11971151
}
11981152

@@ -1202,16 +1156,16 @@ class SimpleStepperWithoutStepControl {
12021156
<mat-step
12031157
*ngFor="let step of steps"
12041158
[label]="step.label"
1205-
[stepControl]="step.control">
1206-
</mat-step>
1159+
[stepControl]="step.control"
1160+
[completed]="step.completed"></mat-step>
12071161
</mat-horizontal-stepper>
12081162
`
12091163
})
12101164
class SimpleStepperWithStepControlAndCompletedBinding {
12111165
steps = [
1212-
{label: 'One', control: new FormControl()},
1213-
{label: 'Two', control: new FormControl()},
1214-
{label: 'Three', control: new FormControl()}
1166+
{label: 'One', completed: false, control: new FormControl()},
1167+
{label: 'Two', completed: false, control: new FormControl()},
1168+
{label: 'Three', completed: false, control: new FormControl()}
12151169
];
12161170
}
12171171

@@ -1223,12 +1177,10 @@ class SimpleStepperWithStepControlAndCompletedBinding {
12231177
<ng-template matStepperIcon="number" let-index="index">
12241178
{{getRomanNumeral(index + 1)}}
12251179
</ng-template>
1226-
<ng-template matStepperIcon="warning">Custom warning</ng-template>
12271180
12281181
<mat-step>Content 1</mat-step>
12291182
<mat-step>Content 2</mat-step>
12301183
<mat-step>Content 3</mat-step>
1231-
<mat-step state="warning">Content 4</mat-step>
12321184
</mat-horizontal-stepper>
12331185
`
12341186
})

0 commit comments

Comments
 (0)