Skip to content

Commit d5ead6b

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

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

src/lib/stepper/stepper.spec.ts

Lines changed: 19 additions & 25 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);
@@ -47,7 +47,7 @@ describe('MdHorizontalStepper', () => {
4747
});
4848

4949
it('should set the "tablist" role on stepper', () => {
50-
stepperEl = fixture.debugElement.query(By.css('md-horizontal-stepper')).nativeElement;
50+
let stepperEl = fixture.debugElement.query(By.css('md-horizontal-stepper')).nativeElement;
5151
expect(stepperEl.getAttribute('role')).toBe('tablist');
5252
});
5353

@@ -125,7 +125,6 @@ describe('MdVerticalStepper', () => {
125125
describe('basic vertical stepper', () => {
126126
let fixture: ComponentFixture<SimpleMdVerticalStepperApp>;
127127
let stepperComponent: MdVerticalStepper;
128-
let stepperEl: HTMLElement;
129128

130129
beforeEach(() => {
131130
fixture = TestBed.createComponent(SimpleMdVerticalStepperApp);
@@ -146,7 +145,7 @@ describe('MdVerticalStepper', () => {
146145
});
147146

148147
it('should set the "tablist" role on stepper', () => {
149-
stepperEl = fixture.debugElement.query(By.css('md-vertical-stepper')).nativeElement;
148+
let stepperEl = fixture.debugElement.query(By.css('md-vertical-stepper')).nativeElement;
150149
expect(stepperEl.getAttribute('role')).toBe('tablist');
151150
});
152151

@@ -209,8 +208,7 @@ describe('MdVerticalStepper', () => {
209208
});
210209
});
211210

212-
function checkSelectionChangeOnHeaderClick(stepperComponent:
213-
MdHorizontalStepper | MdVerticalStepper,
211+
function checkSelectionChangeOnHeaderClick(stepperComponent: MdStepper,
214212
fixture: ComponentFixture<any>,
215213
stepHeaders: DebugElement[]) {
216214
expect(stepperComponent.selectedIndex).toBe(0);
@@ -230,7 +228,7 @@ function checkSelectionChangeOnHeaderClick(stepperComponent:
230228
expect(stepperComponent.selectedIndex).toBe(2);
231229
}
232230

233-
function checkExpandedContent(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
231+
function checkExpandedContent(stepperComponent: MdStepper,
234232
fixture: ComponentFixture<any>,
235233
stepContents: DebugElement[]) {
236234
let firstStepContentEl = stepContents[0].nativeElement;
@@ -244,8 +242,7 @@ function checkExpandedContent(stepperComponent: MdHorizontalStepper | MdVertical
244242
expect(secondStepContentEl.getAttribute('aria-expanded')).toBe('true');
245243
}
246244

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

@@ -262,8 +259,7 @@ function checkCorrectLabel(stepperComponent: MdHorizontalStepper | MdVerticalSte
262259
expect(selectedLabel.textContent).toMatch('New Label');
263260
}
264261

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

269265
let nextButtonNativeEl = fixture.debugElement
@@ -288,8 +284,7 @@ function checkNextStepperButton(stepperComponent: MdHorizontalStepper | MdVertic
288284
expect(stepperComponent.selectedIndex).toBe(2);
289285
}
290286

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

295290
stepperComponent.selectedIndex = 2;
@@ -315,8 +310,7 @@ function checkPreviousStepperButton(stepperComponent: MdHorizontalStepper | MdVe
315310
expect(stepperComponent.selectedIndex).toBe(0);
316311
}
317312

318-
function checkStepPosition(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
319-
fixture: ComponentFixture<any>) {
313+
function checkStepPosition(stepperComponent: MdStepper, fixture: ComponentFixture<any>) {
320314
expect(stepperComponent._getAnimationDirection(0)).toBe('current');
321315
expect(stepperComponent._getAnimationDirection(1)).toBe('next');
322316
expect(stepperComponent._getAnimationDirection(2)).toBe('next');
@@ -336,7 +330,7 @@ function checkStepPosition(stepperComponent: MdHorizontalStepper | MdVerticalSte
336330
expect(stepperComponent._getAnimationDirection(2)).toBe('current');
337331
}
338332

339-
function checkKeyboardEvent(stepperComponent: MdHorizontalStepper | MdVerticalStepper,
333+
function checkKeyboardEvent(stepperComponent: MdStepper,
340334
fixture: ComponentFixture<any>,
341335
stepHeaders: DebugElement[]) {
342336
expect(stepperComponent._focusIndex).toBe(0);
@@ -395,7 +389,7 @@ function checkKeyboardEvent(stepperComponent: MdHorizontalStepper | MdVerticalSt
395389
}
396390

397391
function checkLinearStepperValidity(stepHeaderEl: HTMLElement,
398-
stepperComponent: MdHorizontalStepper | MdVerticalStepper,
392+
stepperComponent: MdStepper,
399393
testComponent:
400394
LinearMdHorizontalStepperApp | LinearMdVerticalStepperApp,
401395
fixture: ComponentFixture<any>) {
@@ -458,9 +452,9 @@ class SimpleMdHorizontalStepperApp {
458452
<md-step [stepControl]="oneGroup">
459453
<form [formGroup]="oneGroup">
460454
<ng-template mdStepLabel>Step one</ng-template>
461-
<md-input-container>
455+
<md-form-field>
462456
<input mdInput formControlName="oneCtrl" required>
463-
</md-input-container>
457+
</md-form-field>
464458
<div>
465459
<button md-button mdStepperPrevious>Back</button>
466460
<button md-button mdStepperNext>Next</button>
@@ -470,9 +464,9 @@ class SimpleMdHorizontalStepperApp {
470464
<md-step [stepControl]="twoGroup">
471465
<form [formGroup]="twoGroup">
472466
<ng-template mdStepLabel>Step two</ng-template>
473-
<md-input-container>
467+
<md-form-field>
474468
<input mdInput formControlName="twoCtrl" required>
475-
</md-input-container>
469+
</md-form-field>
476470
<div>
477471
<button md-button mdStepperPrevious>Back</button>
478472
<button md-button mdStepperNext>Next</button>
@@ -535,9 +529,9 @@ class SimpleMdVerticalStepperApp {
535529
<md-step [stepControl]="oneGroup">
536530
<form [formGroup]="oneGroup">
537531
<ng-template mdStepLabel>Step one</ng-template>
538-
<md-input-container>
532+
<md-form-field>
539533
<input mdInput formControlName="oneCtrl" required>
540-
</md-input-container>
534+
</md-form-field>
541535
<div>
542536
<button md-button mdStepperPrevious>Back</button>
543537
<button md-button mdStepperNext>Next</button>
@@ -547,9 +541,9 @@ class SimpleMdVerticalStepperApp {
547541
<md-step [stepControl]="twoGroup">
548542
<form [formGroup]="twoGroup">
549543
<ng-template mdStepLabel>Step two</ng-template>
550-
<md-input-container>
544+
<md-form-field>
551545
<input mdInput formControlName="twoCtrl" required>
552-
</md-input-container>
546+
</md-form-field>
553547
<div>
554548
<button md-button mdStepperPrevious>Back</button>
555549
<button md-button mdStepperNext>Next</button>

0 commit comments

Comments
 (0)