Skip to content

Commit b660c9a

Browse files
committed
test(stepper): revert unit and e2e tests
1 parent 63fd77d commit b660c9a

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';
@@ -278,62 +278,28 @@ describe('MatStepper', () => {
278278
expect(stepperComponent.selectedIndex).toBe(0);
279279
});
280280

281-
describe('with custom state', () => {
282-
it('should set the custom icon when the step is completed and on selected step', () => {
283-
let stepperComponent = fixture.debugElement
284-
.query(By.directive(MatStepper)).componentInstance;
285-
const firstStep = stepperComponent._steps.toArray()[0];
286-
287-
expect(stepperComponent._getIndicatorType(0, 'warning')).toBe(STEP_STATE.EDIT);
288-
289-
stepperComponent.selectedIndex = 0;
290-
firstStep.completed = true;
291-
fixture.detectChanges();
292-
293-
expect(stepperComponent._getIndicatorType(0, 'warning')).toBe('warning');
294-
});
295-
});
296-
297-
it('should set error icon if step has error', () => {
281+
it('should set create icon if step is editable and completed', () => {
298282
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
299283
let nextButtonNativeEl = fixture.debugElement
300284
.queryAll(By.directive(MatStepperNext))[0].nativeElement;
301-
const firstStep = stepperComponent._steps.toArray()[0];
302-
303-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.EDIT);
304-
305-
firstStep.hasError = true;
285+
expect(stepperComponent._getIndicatorType(0)).toBe('number');
286+
stepperComponent._steps.toArray()[0].editable = true;
306287
nextButtonNativeEl.click();
307288
fixture.detectChanges();
308289

309-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.ERROR);
290+
expect(stepperComponent._getIndicatorType(0)).toBe('edit');
310291
});
311292

312-
it('should set done icon if step is completed', () => {
293+
it('should set done icon if step is not editable and is completed', () => {
313294
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
314295
let nextButtonNativeEl = fixture.debugElement
315296
.queryAll(By.directive(MatStepperNext))[0].nativeElement;
316-
const firstStep = stepperComponent._steps.toArray()[0];
317-
318-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.EDIT);
319-
320-
firstStep.completed = true;
297+
expect(stepperComponent._getIndicatorType(0)).toBe('number');
298+
stepperComponent._steps.toArray()[0].editable = false;
321299
nextButtonNativeEl.click();
322300
fixture.detectChanges();
323301

324-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.DONE);
325-
});
326-
327-
it('should set number icon if step is completed and on selected step', () => {
328-
let stepperComponent = fixture.debugElement.query(By.directive(MatStepper)).componentInstance;
329-
const firstStep = stepperComponent._steps.toArray()[0];
330-
331-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.EDIT);
332-
333-
firstStep.completed = true;
334-
fixture.detectChanges();
335-
336-
expect(stepperComponent._getIndicatorType(0)).toBe(STEP_STATE.NUMBER);
302+
expect(stepperComponent._getIndicatorType(0)).toBe('done');
337303
});
338304

339305
it('should re-render when the i18n labels change', inject([MatStepperIntl],
@@ -418,23 +384,12 @@ describe('MatStepper', () => {
418384
fixture.detectChanges();
419385
});
420386

421-
it('should override any icon', () => {
422-
const stepperDebugElement = fixture.debugElement.query(By.directive(MatStepper));
423-
const stepperComponent: MatStepper = stepperDebugElement.componentInstance;
424-
425-
stepperComponent._steps.toArray()[3].completed = true;
426-
fixture.detectChanges();
427-
428-
const headers = stepperDebugElement.nativeElement.querySelectorAll('mat-step-header');
429-
430-
expect(headers[3].textContent).toContain('Custom warning');
431-
});
432-
433387
it('should allow for the `edit` icon to be overridden', () => {
434388
const stepperDebugElement = fixture.debugElement.query(By.directive(MatStepper));
435389
const stepperComponent: MatStepper = stepperDebugElement.componentInstance;
436390

437391
stepperComponent._steps.toArray()[0].editable = true;
392+
stepperComponent.next();
438393
fixture.detectChanges();
439394

440395
const header = stepperDebugElement.nativeElement.querySelector('mat-step-header');
@@ -731,13 +686,12 @@ describe('MatStepper', () => {
731686

732687
const stepper: MatHorizontalStepper = noStepControlFixture.debugElement
733688
.query(By.directive(MatHorizontalStepper)).componentInstance;
734-
const firstStep = stepper._steps.toArray()[0];
689+
735690
const headers = noStepControlFixture.debugElement
736691
.queryAll(By.css('.mat-horizontal-stepper-header'));
737692

738693
expect(stepper.selectedIndex).toBe(0);
739694

740-
firstStep.completed = false;
741695
headers[1].nativeElement.click();
742696
noStepControlFixture.detectChanges();
743697

@@ -754,16 +708,16 @@ describe('MatStepper', () => {
754708
controlAndBindingFixture.detectChanges();
755709

756710
expect(controlAndBindingFixture.componentInstance.steps[0].control.valid).toBe(true);
711+
expect(controlAndBindingFixture.componentInstance.steps[0].completed).toBe(false);
757712

758713
const stepper: MatHorizontalStepper = controlAndBindingFixture.debugElement
759714
.query(By.directive(MatHorizontalStepper)).componentInstance;
760-
const firstStep = stepper._steps.toArray()[0];
715+
761716
const headers = controlAndBindingFixture.debugElement
762717
.queryAll(By.css('.mat-horizontal-stepper-header'));
763718

764719
expect(stepper.selectedIndex).toBe(0);
765720

766-
firstStep.completed = false;
767721
headers[1].nativeElement.click();
768722
controlAndBindingFixture.detectChanges();
769723

@@ -1169,16 +1123,16 @@ class SimplePreselectedMatHorizontalStepperApp {
11691123
<mat-horizontal-stepper linear>
11701124
<mat-step
11711125
*ngFor="let step of steps"
1172-
[label]="step.label">
1173-
</mat-step>
1126+
[label]="step.label"
1127+
[completed]="step.completed"></mat-step>
11741128
</mat-horizontal-stepper>
11751129
`
11761130
})
11771131
class SimpleStepperWithoutStepControl {
11781132
steps = [
1179-
{label: 'One'},
1180-
{label: 'Two'},
1181-
{label: 'Three'}
1133+
{label: 'One', completed: false},
1134+
{label: 'Two', completed: false},
1135+
{label: 'Three', completed: false}
11821136
];
11831137
}
11841138

@@ -1188,16 +1142,16 @@ class SimpleStepperWithoutStepControl {
11881142
<mat-step
11891143
*ngFor="let step of steps"
11901144
[label]="step.label"
1191-
[stepControl]="step.control">
1192-
</mat-step>
1145+
[stepControl]="step.control"
1146+
[completed]="step.completed"></mat-step>
11931147
</mat-horizontal-stepper>
11941148
`
11951149
})
11961150
class SimpleStepperWithStepControlAndCompletedBinding {
11971151
steps = [
1198-
{label: 'One', control: new FormControl()},
1199-
{label: 'Two', control: new FormControl()},
1200-
{label: 'Three', control: new FormControl()}
1152+
{label: 'One', completed: false, control: new FormControl()},
1153+
{label: 'Two', completed: false, control: new FormControl()},
1154+
{label: 'Three', completed: false, control: new FormControl()}
12011155
];
12021156
}
12031157

@@ -1209,12 +1163,10 @@ class SimpleStepperWithStepControlAndCompletedBinding {
12091163
<ng-template matStepperIcon="number" let-index="index">
12101164
{{getRomanNumeral(index + 1)}}
12111165
</ng-template>
1212-
<ng-template matStepperIcon="warning">Custom warning</ng-template>
12131166
12141167
<mat-step>Content 1</mat-step>
12151168
<mat-step>Content 2</mat-step>
12161169
<mat-step>Content 3</mat-step>
1217-
<mat-step state="warning">Content 4</mat-step>
12181170
</mat-horizontal-stepper>
12191171
`
12201172
})

0 commit comments

Comments
 (0)