-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(stepper): Add unit tests for stepper #6428
Conversation
@g1shin @jelbourn Been playing with the stepper branch. Any particular reason for the label's index not being part of the whole custom label? Instead of: <div class="mat-stepper-index">{{i + 1}}</div>
<div class="mat-stepper-label">
<!-- If there is a label template, use it. -->
<ng-container *ngIf="step.stepLabel" [ngTemplateOutlet]="step.stepLabel.template"></ng-container>
<!-- It there is no label template, fall back to the text label. -->
<div *ngIf="!step.stepLabel">{{step.label}}</div>
</div> do it like: <div class="mat-stepper-label">
<ng-container *ngIf="step.stepLabel" [ngTemplateOutlet]="step.stepLabel.template"></ng-container>
<!-- It there is no label template, fall back to the text label. -->
<div *ngIf="!step.stepLabel">
<div class="mat-stepper-index">
{{i + 1}}
</div>
{{step.label}}
</div>
</div> This way if a user opts-in for a custom label he will decide if to include the index or not. Forcing the index does not allow real customization of the index, for example if I want to do roman numerals or A. B. C Since the user will do |
Another thing that pops out is not using This does not align with other components... EDIT: Also not using
|
@g1shin needs rebase |
Rebase done; ready for review 👍 |
src/lib/stepper/stepper.spec.ts
Outdated
import {dispatchKeyboardEvent} from '@angular/cdk/testing'; | ||
import {ENTER, LEFT_ARROW, RIGHT_ARROW, SPACE} from '@angular/cdk/keycodes'; | ||
|
||
fdescribe('MdHorizontalStepper', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you left an fdescribe
by mistake. Remove?
src/lib/stepper/stepper.spec.ts
Outdated
fdescribe('MdHorizontalStepper', () => { | ||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MdStepperModule, NoopAnimationsModule, FormsModule, ReactiveFormsModule], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need FormsModule
? It looks like you aren't using any template-driven directives. Same on line 114.
src/lib/stepper/stepper.spec.ts
Outdated
}); | ||
|
||
it('should change selected index on header click', () => { | ||
let stepHeader = fixture.debugElement.queryAll(By.css('.mat-horizontal-stepper-header')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe name this stepHeaders
(plural)? To make clear that this grabs headers from all steps. Same on line 142.
src/lib/stepper/stepper.spec.ts
Outdated
fixture.detectChanges(); | ||
|
||
expect(stepContentEl.getAttribute('aria-expanded')).toBe('false'); | ||
stepContentEl = stepContent[1].nativeElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It's a bit hard to follow when you're naming two different step elements with the same name. Maybe create a new let
for this - secondStepEl
?
src/lib/stepper/stepper.spec.ts
Outdated
expect(stepperEl.getAttribute('role')).toBe('tablist'); | ||
}); | ||
|
||
it('should expand the right content', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: In this case, you mean set aria-expanded
correctly, right? I'd mention that in the test name. Same on line 152.
src/lib/stepper/stepper.spec.ts
Outdated
|
||
it('should not move to next step if current step is not valid', () => { | ||
expect(testComponent.oneGroup.get('oneCtrl')!.value).toBe(''); | ||
expect(testComponent.oneGroup.valid).toBe(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Here I'd expect a test that the control itself is invalid (if you were to add another control, it could cause the parent form to be false for a different reason). Same on 199.
src/lib/stepper/stepper.spec.ts
Outdated
}); | ||
}); | ||
|
||
fdescribe('MdVerticalStepper', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fdescribe
src/lib/stepper/stepper.spec.ts
Outdated
dispatchKeyboardEvent(stepHeaderEl, 'keydown', RIGHT_ARROW); | ||
fixture.detectChanges(); | ||
|
||
expect(stepperComponent._focusIndex).toBe(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think fallback messages for these would be helpful to guide us through your thinking.
src/lib/stepper/stepper.spec.ts
Outdated
<md-step [stepControl]="oneGroup"> | ||
<form [formGroup]="oneGroup"> | ||
<ng-template mdStepLabel>Step one</ng-template> | ||
<md-input-container> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to use md-form-field on these to be forward-friendly? cc @mmalerba
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 if you're synced up to where md-form-field exists
Changes have been made based on review. Ready for review again 😃 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mmalerba Do you want to take a look before I apply merge labels? |
src/lib/stepper/stepper.spec.ts
Outdated
describe('basic horizontal stepper', () => { | ||
let fixture: ComponentFixture<SimpleMdHorizontalStepperApp>; | ||
let stepperComponent: MdHorizontalStepper; | ||
let stepperEl: HTMLElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since only 1 test uses this you can just declare it in that test
src/lib/stepper/stepper.spec.ts
Outdated
}); | ||
|
||
function checkSelectionChangeOnHeaderClick(stepperComponent: | ||
MdHorizontalStepper | MdVerticalStepper, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just use common base class MdStepper? (here and other functions that take a stepper)
src/lib/stepper/stepper.spec.ts
Outdated
<md-step [stepControl]="oneGroup"> | ||
<form [formGroup]="oneGroup"> | ||
<ng-template mdStepLabel>Step one</ng-template> | ||
<md-input-container> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 if you're synced up to where md-form-field exists
Ready for review again |
src/lib/stepper/stepper.spec.ts
Outdated
it('should change selected index on header click', () => { | ||
let stepHeaders = fixture.debugElement.queryAll(By.css('.mat-horizontal-stepper-header')); | ||
checkSelectionChangeOnHeaderClick(stepperComponent, fixture, stepHeaders); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra line
* Add unit tests for stepper * Changes made based on review * More changes based on review
* Add unit tests for stepper * Changes made based on review * More changes based on review
* Add unit tests for stepper * Changes made based on review * More changes based on review
* Add unit tests for stepper * Changes made based on review * More changes based on review
* Add unit tests for stepper * Changes made based on review * More changes based on review
…tepper branch. (#5742) * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Adding "selectedIndex" attribute to stepper and working on TemplateOulet. * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Template rendering and selectIndex control done. * Work in progress for accessibility * Added functionalities based on the tentative API doc. * Refactor code for cdk-stepper and cdk-step * Add support for templated label * Added support for keyboard events and focus changes for accessibility. * Updated vertical stepper + added comments * Fix package-lock.json * Fix indention * Changes made based on the review * Changes based on review - event properties, selectors, SPACE support, etc. + demo * Add select() for step component + refactor to avoid circular dependency + support cycling using arrow keys * API change based on review * Minor code clean up based on review. * Several name changes, etc based on review * Add to compatibility mode list and refactor to avoid circular dependency feat(stepper): Create stepper button directives to enable adding buttons to stepper (#5951) * Create stepper button directives to enable adding buttons to stepper * Changes made based on review * Minor changes with click handlers Build changes feat(stepper): Add initial styles to stepper based on Material guidelines (#6242) * Add initial styles to stepper based on Material guidelines * Fix flex-shrink and min-width * Changes made based on review * Fix alignment * Margin modifications feat(stepper): Add support for linear stepper (#6116) * Add form controls and custom error state matcher * Modify form controls for stepper-demo and add custom validator * Move custom step validation function so that users can simply import and use * Implement @input() stepControl for each step * Add linear attribute to stepper * Add enabling/disabling linear state of demo feat(stepper): Add animation to stepper (#6361) * Add animation * Implement Angular animation * Clean up unnecessary code * Generalize animation so that vertical and horizontal steppers can use the same function Rebase onto upstream/master feat(stepper): Add unit tests for stepper (#6428) * Add unit tests for stepper * Changes made based on review * More changes based on review feat(stepper): Add support for linear stepper #2 - each step as its own form. (#6117) * Add form control - consider each step as its own form group * Comment edits * Add 'valid' to MdStep for form validation * Add [stepControl] to each step based on merging * Changes based on review Fix focus logic and CSS changes (#6507) feat(stepper): Add documentation for stepper (#6533) * Documentation for stepper * Revision based on review + add accessibility section feat(stepper): Support additional properties for step (#6509) * Additional properties for step * Unit tests * Code changes based on review + test name changes * Refactor code for shared functionality between vertical and horizontal stepper * Refactor md-step-header and md-step-content + optional step change * Simplify code based on review * Changes to step-header based on review * Minor changes Fix host style and demo page (#6592) Revert package.json and package-lock.json Changes made along with BUILD changes in google3 Add typography mixin Changes to address aot compiler failures fix rtl bugs
…tepper branch. (angular#5742) * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Adding "selectedIndex" attribute to stepper and working on TemplateOulet. * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Template rendering and selectIndex control done. * Work in progress for accessibility * Added functionalities based on the tentative API doc. * Refactor code for cdk-stepper and cdk-step * Add support for templated label * Added support for keyboard events and focus changes for accessibility. * Updated vertical stepper + added comments * Fix package-lock.json * Fix indention * Changes made based on the review * Changes based on review - event properties, selectors, SPACE support, etc. + demo * Add select() for step component + refactor to avoid circular dependency + support cycling using arrow keys * API change based on review * Minor code clean up based on review. * Several name changes, etc based on review * Add to compatibility mode list and refactor to avoid circular dependency feat(stepper): Create stepper button directives to enable adding buttons to stepper (angular#5951) * Create stepper button directives to enable adding buttons to stepper * Changes made based on review * Minor changes with click handlers Build changes feat(stepper): Add initial styles to stepper based on Material guidelines (angular#6242) * Add initial styles to stepper based on Material guidelines * Fix flex-shrink and min-width * Changes made based on review * Fix alignment * Margin modifications feat(stepper): Add support for linear stepper (angular#6116) * Add form controls and custom error state matcher * Modify form controls for stepper-demo and add custom validator * Move custom step validation function so that users can simply import and use * Implement @input() stepControl for each step * Add linear attribute to stepper * Add enabling/disabling linear state of demo feat(stepper): Add animation to stepper (angular#6361) * Add animation * Implement Angular animation * Clean up unnecessary code * Generalize animation so that vertical and horizontal steppers can use the same function Rebase onto upstream/master feat(stepper): Add unit tests for stepper (angular#6428) * Add unit tests for stepper * Changes made based on review * More changes based on review feat(stepper): Add support for linear stepper angular#2 - each step as its own form. (angular#6117) * Add form control - consider each step as its own form group * Comment edits * Add 'valid' to MdStep for form validation * Add [stepControl] to each step based on merging * Changes based on review Fix focus logic and CSS changes (angular#6507) feat(stepper): Add documentation for stepper (angular#6533) * Documentation for stepper * Revision based on review + add accessibility section feat(stepper): Support additional properties for step (angular#6509) * Additional properties for step * Unit tests * Code changes based on review + test name changes * Refactor code for shared functionality between vertical and horizontal stepper * Refactor md-step-header and md-step-content + optional step change * Simplify code based on review * Changes to step-header based on review * Minor changes Fix host style and demo page (angular#6592) Revert package.json and package-lock.json Changes made along with BUILD changes in google3 Add typography mixin Changes to address aot compiler failures fix rtl bugs
…tepper branch. (angular#5742) * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Adding "selectedIndex" attribute to stepper and working on TemplateOulet. * Prototyping * Further work * Further prototyping * Further prototyping * Further work * Adding event emitters * Template rendering and selectIndex control done. * Work in progress for accessibility * Added functionalities based on the tentative API doc. * Refactor code for cdk-stepper and cdk-step * Add support for templated label * Added support for keyboard events and focus changes for accessibility. * Updated vertical stepper + added comments * Fix package-lock.json * Fix indention * Changes made based on the review * Changes based on review - event properties, selectors, SPACE support, etc. + demo * Add select() for step component + refactor to avoid circular dependency + support cycling using arrow keys * API change based on review * Minor code clean up based on review. * Several name changes, etc based on review * Add to compatibility mode list and refactor to avoid circular dependency feat(stepper): Create stepper button directives to enable adding buttons to stepper (angular#5951) * Create stepper button directives to enable adding buttons to stepper * Changes made based on review * Minor changes with click handlers Build changes feat(stepper): Add initial styles to stepper based on Material guidelines (angular#6242) * Add initial styles to stepper based on Material guidelines * Fix flex-shrink and min-width * Changes made based on review * Fix alignment * Margin modifications feat(stepper): Add support for linear stepper (angular#6116) * Add form controls and custom error state matcher * Modify form controls for stepper-demo and add custom validator * Move custom step validation function so that users can simply import and use * Implement @input() stepControl for each step * Add linear attribute to stepper * Add enabling/disabling linear state of demo feat(stepper): Add animation to stepper (angular#6361) * Add animation * Implement Angular animation * Clean up unnecessary code * Generalize animation so that vertical and horizontal steppers can use the same function Rebase onto upstream/master feat(stepper): Add unit tests for stepper (angular#6428) * Add unit tests for stepper * Changes made based on review * More changes based on review feat(stepper): Add support for linear stepper angular#2 - each step as its own form. (angular#6117) * Add form control - consider each step as its own form group * Comment edits * Add 'valid' to MdStep for form validation * Add [stepControl] to each step based on merging * Changes based on review Fix focus logic and CSS changes (angular#6507) feat(stepper): Add documentation for stepper (angular#6533) * Documentation for stepper * Revision based on review + add accessibility section feat(stepper): Support additional properties for step (angular#6509) * Additional properties for step * Unit tests * Code changes based on review + test name changes * Refactor code for shared functionality between vertical and horizontal stepper * Refactor md-step-header and md-step-content + optional step change * Simplify code based on review * Changes to step-header based on review * Minor changes Fix host style and demo page (angular#6592) Revert package.json and package-lock.json Changes made along with BUILD changes in google3 Add typography mixin Changes to address aot compiler failures fix rtl bugs
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.