Skip to content

Commit

Permalink
- fix #183
Browse files Browse the repository at this point in the history
  • Loading branch information
madoar committed Feb 5, 2019
1 parent deb26a6 commit 830aeb7
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/wizard-navigation-bar.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul class="steps-indicator steps-{{numberOfWizardSteps}}">
<li *ngFor="let step of wizardSteps"
<li [attr.id]="step.stepId" *ngFor="let step of wizardSteps"
[ngClass]="{
default: isDefault(step),
current: isCurrent(step),
Expand Down
65 changes: 50 additions & 15 deletions src/lib/components/wizard-navigation-bar.component.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
import {Component, ViewChild} from '@angular/core';
import {Component, DebugElement, ViewChild} from '@angular/core';
import {WizardNavigationBarComponent} from './wizard-navigation-bar.component';
import {WizardComponent} from './wizard.component';
import {By} from '@angular/platform-browser';
Expand All @@ -11,15 +11,17 @@ import {WizardState} from '../navigation/wizard-state.model';
selector: 'aw-test-wizard',
template: `
<aw-wizard>
<aw-wizard-step stepTitle='Steptitle 1'>Step 1</aw-wizard-step>
<aw-wizard-step stepTitle='Steptitle 1' [stepId]="firstStepId">Step 1</aw-wizard-step>
<aw-wizard-step stepTitle='Steptitle 2' awOptionalStep>Step 2</aw-wizard-step>
<aw-wizard-step stepTitle='Steptitle 3'>Step 3</aw-wizard-step>
</aw-wizard>
`
})
class WizardTestComponent {
public firstStepId = 'step1';

@ViewChild(WizardComponent)
wizard: WizardComponent;
public wizard: WizardComponent;
}

describe('WizardNavigationBarComponent', () => {
Expand Down Expand Up @@ -459,8 +461,10 @@ describe('WizardNavigationBarComponent', () => {
it('should use the \"small\" layout when no navigation bar layout is specified', () => {
const navBar = wizardTestFixture.debugElement.query(By.css('aw-wizard-navigation-bar'));

expect(navBar.classes).toEqual({ 'horizontal': true, 'vertical': false, 'small': true,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': false });
expect(navBar.classes).toEqual({
'horizontal': true, 'vertical': false, 'small': true,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': false
});
});

it('should use the \"small\" layout when it is specified', () => {
Expand All @@ -469,8 +473,10 @@ describe('WizardNavigationBarComponent', () => {
wizardTest.wizard.navBarLayout = 'small';
wizardTestFixture.detectChanges();

expect(navBar.classes).toEqual({ 'horizontal': true, 'vertical': false, 'small': true,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': false });
expect(navBar.classes).toEqual({
'horizontal': true, 'vertical': false, 'small': true,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': false
});
});

it('should use the \"large-filled\" layout when it is specified', () => {
Expand All @@ -479,8 +485,10 @@ describe('WizardNavigationBarComponent', () => {
wizardTest.wizard.navBarLayout = 'large-filled';
wizardTestFixture.detectChanges();

expect(navBar.classes).toEqual({ 'horizontal': true, 'vertical': false, 'small': false,
'large-filled': true, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': false });
expect(navBar.classes).toEqual({
'horizontal': true, 'vertical': false, 'small': false,
'large-filled': true, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': false
});
});

it('should use the \"large-empty\" layout when it is specified', () => {
Expand All @@ -489,8 +497,10 @@ describe('WizardNavigationBarComponent', () => {
wizardTest.wizard.navBarLayout = 'large-empty';
wizardTestFixture.detectChanges();

expect(navBar.classes).toEqual({ 'horizontal': true, 'vertical': false, 'small': false,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': true, 'large-empty-symbols': false });
expect(navBar.classes).toEqual({
'horizontal': true, 'vertical': false, 'small': false,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': true, 'large-empty-symbols': false
});
});

it('should use the \"large-filled-symbols\" layout when it is specified', () => {
Expand All @@ -499,8 +509,10 @@ describe('WizardNavigationBarComponent', () => {
wizardTest.wizard.navBarLayout = 'large-filled-symbols';
wizardTestFixture.detectChanges();

expect(navBar.classes).toEqual({ 'horizontal': true, 'vertical': false, 'small': false,
'large-filled': false, 'large-filled-symbols': true, 'large-empty': false, 'large-empty-symbols': false });
expect(navBar.classes).toEqual({
'horizontal': true, 'vertical': false, 'small': false,
'large-filled': false, 'large-filled-symbols': true, 'large-empty': false, 'large-empty-symbols': false
});
});

it('should use the \"large-empty-symbols\" layout when it is specified', () => {
Expand All @@ -509,8 +521,10 @@ describe('WizardNavigationBarComponent', () => {
wizardTest.wizard.navBarLayout = 'large-empty-symbols';
wizardTestFixture.detectChanges();

expect(navBar.classes).toEqual({ 'horizontal': true, 'vertical': false, 'small': false,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': true });
expect(navBar.classes).toEqual({
'horizontal': true, 'vertical': false, 'small': false,
'large-filled': false, 'large-filled-symbols': false, 'large-empty': false, 'large-empty-symbols': true
});
});

it('should show the correct step titles', () => {
Expand All @@ -533,4 +547,25 @@ describe('WizardNavigationBarComponent', () => {
expect(navigationLinks[1].nativeElement.innerText).toBe('STEPTITLE 2');
expect(navigationLinks[2].nativeElement.innerText).toBe('STEPTITLE 1');
});

it('should have the correct stepId', () => {
const navigationLiElements = wizardTestFixture.debugElement.queryAll(By.css('aw-wizard-navigation-bar ul li'));

expect(navigationLiElements.length).toBe(3);
expect(navigationLiElements[0].nativeElement.id).toBe('step1');
expect(navigationLiElements[1].nativeElement.id).toBe('');
expect(navigationLiElements[2].nativeElement.id).toBe('');
});

it('should change the stepId correctly', () => {
wizardTest.firstStepId = null;
wizardTestFixture.detectChanges();

const navigationLiElements = wizardTestFixture.debugElement.queryAll(By.css('aw-wizard-navigation-bar ul li'));

expect(navigationLiElements.length).toBe(3);
expect(navigationLiElements[0].nativeElement.id).toBe('');
expect(navigationLiElements[1].nativeElement.id).toBe('');
expect(navigationLiElements[2].nativeElement.id).toBe('');
});
});

0 comments on commit 830aeb7

Please sign in to comment.