Skip to content

Commit 9933bbc

Browse files
committed
More changes based on review
1 parent 60e8044 commit 9933bbc

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

src/lib/stepper/stepper.spec.ts

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/
99
import {MdStepperNext, MdStepperPrevious} from './stepper-button';
1010
import {dispatchKeyboardEvent} from '@angular/cdk/testing';
1111
import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes';
12+
import {MdStepper} from './stepper';
1213

1314
describe('MdHorizontalStepper', () => {
1415
beforeEach(async(() => {
@@ -26,7 +27,6 @@ describe('MdHorizontalStepper', () => {
2627
describe('basic horizontal stepper', () => {
2728
let fixture: ComponentFixture<SimpleMdHorizontalStepperApp>;
2829
let stepperComponent: MdHorizontalStepper;
29-
let stepperEl: HTMLElement;
3030

3131
beforeEach(() => {
3232
fixture = TestBed.createComponent(SimpleMdHorizontalStepperApp);
@@ -43,11 +43,10 @@ describe('MdHorizontalStepper', () => {
4343
it('should change selected index on header click', () => {
4444
let stepHeaders = fixture.debugElement.queryAll(By.css('.mat-horizontal-stepper-header'));
4545
checkSelectionChangeOnHeaderClick(stepperComponent, fixture, stepHeaders);
46-
4746
});
4847

4948
it('should set the "tablist" role on stepper', () => {
50-
stepperEl = fixture.debugElement.query(By.css('md-horizontal-stepper')).nativeElement;
49+
let stepperEl = fixture.debugElement.query(By.css('md-horizontal-stepper')).nativeElement;
5150
expect(stepperEl.getAttribute('role')).toBe('tablist');
5251
});
5352

@@ -125,7 +124,6 @@ describe('MdVerticalStepper', () => {
125124
describe('basic vertical stepper', () => {
126125
let fixture: ComponentFixture<SimpleMdVerticalStepperApp>;
127126
let stepperComponent: MdVerticalStepper;
128-
let stepperEl: HTMLElement;
129127

130128
beforeEach(() => {
131129
fixture = TestBed.createComponent(SimpleMdVerticalStepperApp);
@@ -146,7 +144,7 @@ describe('MdVerticalStepper', () => {
146144
});
147145

148146
it('should set the "tablist" role on stepper', () => {
149-
stepperEl = fixture.debugElement.query(By.css('md-vertical-stepper')).nativeElement;
147+
let stepperEl = fixture.debugElement.query(By.css('md-vertical-stepper')).nativeElement;
150148
expect(stepperEl.getAttribute('role')).toBe('tablist');
151149
});
152150

@@ -209,8 +207,7 @@ describe('MdVerticalStepper', () => {
209207
});
210208
});
211209

212-
function checkSelectionChangeOnHeaderClick(stepperComponent:
213-
MdHorizontalStepper | MdVerticalStepper,
210+
function checkSelectionChangeOnHeaderClick(stepperComponent: MdStepper,
214211
fixture: ComponentFixture<any>,
215212
stepHeaders: DebugElement[]) {
216213
expect(stepperComponent.selectedIndex).toBe(0);
@@ -230,7 +227,7 @@ function checkSelectionChangeOnHeaderClick(stepperComponent:
230227
expect(stepperComponent.selectedIndex).toBe(2);
231228
}
232229

233-
function checkExpandedContent(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
230+
function checkExpandedContent(stepperComponent: MdStepper,
234231
fixture: ComponentFixture<any>,
235232
stepContents: DebugElement[]) {
236233
let firstStepContentEl = stepContents[0].nativeElement;
@@ -244,8 +241,7 @@ function checkExpandedContent(stepperComponent: MdHorizontalStepper | MdVertical
244241
expect(secondStepContentEl.getAttribute('aria-expanded')).toBe('true');
245242
}
246243

247-
function checkCorrectLabel(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
248-
fixture: ComponentFixture<any>) {
244+
function checkCorrectLabel(stepperComponent: MdStepper, fixture: ComponentFixture<any>) {
249245
let selectedLabel = fixture.nativeElement.querySelector('[aria-selected="true"]');
250246
expect(selectedLabel.textContent).toMatch('Step 1');
251247

@@ -262,8 +258,7 @@ function checkCorrectLabel(stepperComponent: MdHorizontalStepper | MdVerticalSte
262258
expect(selectedLabel.textContent).toMatch('New Label');
263259
}
264260

265-
function checkNextStepperButton(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
266-
fixture: ComponentFixture<any>) {
261+
function checkNextStepperButton(stepperComponent: MdStepper, fixture: ComponentFixture<any>) {
267262
expect(stepperComponent.selectedIndex).toBe(0);
268263

269264
let nextButtonNativeEl = fixture.debugElement
@@ -288,8 +283,7 @@ function checkNextStepperButton(stepperComponent: MdHorizontalStepper | MdVertic
288283
expect(stepperComponent.selectedIndex).toBe(2);
289284
}
290285

291-
function checkPreviousStepperButton(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
292-
fixture: ComponentFixture<any>) {
286+
function checkPreviousStepperButton(stepperComponent: MdStepper, fixture: ComponentFixture<any>) {
293287
expect(stepperComponent.selectedIndex).toBe(0);
294288

295289
stepperComponent.selectedIndex = 2;
@@ -315,8 +309,7 @@ function checkPreviousStepperButton(stepperComponent: MdHorizontalStepper | MdVe
315309
expect(stepperComponent.selectedIndex).toBe(0);
316310
}
317311

318-
function checkStepPosition(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
319-
fixture: ComponentFixture<any>) {
312+
function checkStepPosition(stepperComponent: MdStepper, fixture: ComponentFixture<any>) {
320313
expect(stepperComponent._getAnimationDirection(0)).toBe('current');
321314
expect(stepperComponent._getAnimationDirection(1)).toBe('next');
322315
expect(stepperComponent._getAnimationDirection(2)).toBe('next');
@@ -336,7 +329,7 @@ function checkStepPosition(stepperComponent: MdHorizontalStepper | MdVerticalSte
336329
expect(stepperComponent._getAnimationDirection(2)).toBe('current');
337330
}
338331

339-
function checkKeyboardEvent(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
332+
function checkKeyboardEvent(stepperComponent: MdStepper,
340333
fixture: ComponentFixture<any>,
341334
stepHeaders: DebugElement[]) {
342335
expect(stepperComponent._focusIndex).toBe(0);
@@ -395,7 +388,7 @@ function checkKeyboardEvent(stepperComponent: MdHorizontalStepper | MdVerticalSt
395388
}
396389

397390
function checkLinearStepperValidity(stepHeaderEl: HTMLElement,
398-
stepperComponent: MdHorizontalStepper | MdVerticalStepper,
391+
stepperComponent: MdStepper,
399392
testComponent:
400393
LinearMdHorizontalStepperApp | LinearMdVerticalStepperApp,
401394
fixture: ComponentFixture<any>) {
@@ -458,9 +451,9 @@ class SimpleMdHorizontalStepperApp {
458451
<md-step [stepControl]="oneGroup">
459452
<form [formGroup]="oneGroup">
460453
<ng-template mdStepLabel>Step one</ng-template>
461-
<md-input-container>
454+
<md-form-field>
462455
<input mdInput formControlName="oneCtrl" required>
463-
</md-input-container>
456+
</md-form-field>
464457
<div>
465458
<button md-button mdStepperPrevious>Back</button>
466459
<button md-button mdStepperNext>Next</button>
@@ -470,9 +463,9 @@ class SimpleMdHorizontalStepperApp {
470463
<md-step [stepControl]="twoGroup">
471464
<form [formGroup]="twoGroup">
472465
<ng-template mdStepLabel>Step two</ng-template>
473-
<md-input-container>
466+
<md-form-field>
474467
<input mdInput formControlName="twoCtrl" required>
475-
</md-input-container>
468+
</md-form-field>
476469
<div>
477470
<button md-button mdStepperPrevious>Back</button>
478471
<button md-button mdStepperNext>Next</button>
@@ -535,9 +528,9 @@ class SimpleMdVerticalStepperApp {
535528
<md-step [stepControl]="oneGroup">
536529
<form [formGroup]="oneGroup">
537530
<ng-template mdStepLabel>Step one</ng-template>
538-
<md-input-container>
531+
<md-form-field>
539532
<input mdInput formControlName="oneCtrl" required>
540-
</md-input-container>
533+
</md-form-field>
541534
<div>
542535
<button md-button mdStepperPrevious>Back</button>
543536
<button md-button mdStepperNext>Next</button>
@@ -547,9 +540,9 @@ class SimpleMdVerticalStepperApp {
547540
<md-step [stepControl]="twoGroup">
548541
<form [formGroup]="twoGroup">
549542
<ng-template mdStepLabel>Step two</ng-template>
550-
<md-input-container>
543+
<md-form-field>
551544
<input mdInput formControlName="twoCtrl" required>
552-
</md-input-container>
545+
</md-form-field>
553546
<div>
554547
<button md-button mdStepperPrevious>Back</button>
555548
<button md-button mdStepperNext>Next</button>

0 commit comments

Comments
 (0)