Skip to content

Commit b1d7911

Browse files
committed
- improved css for the nav bar
- removed nav-bar classes top and bottom, because they aren't needed anymore - added badge to README.md to show the dependency licence status - improved nav bar test
1 parent fac0dc6 commit b1d7911

File tree

7 files changed

+43
-34
lines changed

7 files changed

+43
-34
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Build Status](https://travis-ci.org/madoar/ng2-wizard.png)](https://travis-ci.org/madoar/ng2-wizard)
44
[![Dependency Status](https://david-dm.org/madoar/ng2-wizard.svg)](https://david-dm.org/madoar/ng2-wizard)
55
[![Dev-Dependency Status](https://david-dm.org/madoar/ng2-wizard/dev-status.svg)](https://david-dm.org/madoar/ng2-wizard?type=dev)
6+
[![Dependency Licence Status](https://dependencyci.com/github/madoar/ng2-wizard/badge)](https://dependencyci.com/github/madoar/ng2-wizard)
67

78
This project contains a functional wizard component for [Angular 2](https://angular.io/).
89

src/components/components/wizard-navigation-bar.component.less

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@wz-color-editing: #FF0000;
66

77
.steps-indicator {
8+
padding: 10px 0 25px 0;
89
list-style: none;
910

1011
&:before {
@@ -71,8 +72,7 @@
7172
position: relative;
7273
float: left;
7374
margin: 0;
74-
padding: 0;
75-
padding-top: 10px;
75+
padding: 10px 0 0 0;
7676
text-align: center;
7777
line-height: 15px;
7878

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
/* tslint:disable:no-unused-variable */
2-
import {async, ComponentFixture, TestBed} from '@angular/core/testing';
3-
import {DebugElement, QueryList} from '@angular/core';
2+
import {async, ComponentFixture, TestBed} from "@angular/core/testing";
3+
import {QueryList, ViewChild, Component, ContentChild, OnInit} from "@angular/core";
4+
import {WizardNavigationBarComponent} from "./wizard-navigation-bar.component";
5+
import {WizardComponent} from "./wizard.component";
6+
import {WizardStepComponent} from "./wizard-step.component";
7+
import {GoToStepDirective} from "../directives/go-to-step.directive";
8+
import {By} from "@angular/platform-browser";
49

5-
import {WizardNavigationBarComponent} from './wizard-navigation-bar.component';
6-
import {WizardComponent} from './wizard.component';
7-
import {WizardStepComponent} from './wizard-step.component';
8-
import {GoToStepDirective} from '../directives/go-to-step.directive';
10+
@Component({
11+
selector: 'test-wizard',
12+
template: `
13+
<wizard>
14+
<wizard-step title='Steptitle 1'>Step 1</wizard-step>
15+
<wizard-step title='Steptitle 2'>Step 2</wizard-step>
16+
<wizard-step title='Steptitle 3'>Step 3</wizard-step>
17+
</wizard>
18+
`
19+
})
20+
class WizardTestComponent {
21+
@ViewChild(WizardComponent)
22+
public wizard: WizardComponent;
23+
}
924

1025
describe('WizardNavigationBarComponent', () => {
11-
let component: WizardNavigationBarComponent;
12-
let fixture: ComponentFixture<WizardNavigationBarComponent>;
26+
let wizardTest: WizardTestComponent;
27+
let wizardTestFixture: ComponentFixture<WizardTestComponent>;
1328

1429
beforeEach(async(() => {
15-
let wizard = new WizardComponent();
16-
17-
wizard.wizardSteps = new QueryList<WizardStepComponent>();
18-
1930
TestBed.configureTestingModule({
20-
declarations: [WizardNavigationBarComponent, WizardComponent, WizardStepComponent, GoToStepDirective],
21-
providers: [{ provide: WizardComponent, useValue: wizard }]
31+
declarations: [ WizardComponent, WizardStepComponent, WizardNavigationBarComponent, WizardTestComponent, GoToStepDirective ]
2232
})
2333
.compileComponents();
2434
}));
2535

2636
beforeEach(() => {
27-
fixture = TestBed.createComponent(WizardNavigationBarComponent);
28-
component = fixture.componentInstance;
29-
fixture.detectChanges();
37+
wizardTestFixture = TestBed.createComponent(WizardTestComponent);
38+
wizardTest = wizardTestFixture.componentInstance;
39+
wizardTestFixture.detectChanges();
3040
});
3141

3242
it('should create', () => {
33-
expect(component).toBeTruthy();
43+
expect(wizardTest).toBeTruthy();
44+
expect(wizardTestFixture.debugElement.query(By.css('wizard-navigation-bar'))).toBeTruthy();
3445
});
3546
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.step {
2+
height: auto;
3+
width: 100%;
4+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<div class="wizard-centered">
2-
<wizard-navigation-bar *ngIf="navBarLocation == 'top'" [ngClass]="['nav-bar', 'top']"></wizard-navigation-bar>
2+
<wizard-navigation-bar class="nav-bar" *ngIf="navBarLocation == 'top'"></wizard-navigation-bar>
33

44
<div class="steps">
55
<ng-content></ng-content>
66
</div>
77

8-
<wizard-navigation-bar *ngIf="navBarLocation == 'bottom'" [ngClass]="['nav-bar', 'bottom']"></wizard-navigation-bar>
8+
<wizard-navigation-bar class="nav-bar" *ngIf="navBarLocation == 'bottom'"></wizard-navigation-bar>
99
</div>

src/components/components/wizard.component.less

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,5 @@
99
margin: 0;
1010
width: 100%;
1111
height: auto;
12-
overflow: hidden;
13-
14-
&.top {
15-
padding-bottom: 10px;
16-
}
17-
18-
&.bottom {
19-
padding-top: 10px;
20-
}
2112
}
2213
}

src/components/components/wizard.component.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,29 +59,31 @@ describe('WizardComponent', () => {
5959

6060
it('should create', () => {
6161
expect(wizardTest).toBeTruthy();
62+
expect(wizardTest.wizard).toBeTruthy();
63+
expect(wizardTestFixture.debugElement.query(By.css('wizard'))).toBeTruthy();
6264
});
6365

6466
it('should contain navigation bar at the correct position', () => {
6567
// check default: the navbar should be at the top of the wizard if no navBarLocation was set
6668
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar"))).toBeTruthy();
6769
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :first-child")).name).toBe('wizard-navigation-bar');
68-
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar.top"))).toBeTruthy();
70+
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :last-child")).name).toBe('div');
6971

7072
wizardTest.wizard.navBarLocation = "bottom";
7173
wizardTestFixture.detectChanges();
7274

7375
// navBar should be at the bottom of the wizard
7476
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar"))).toBeTruthy();
77+
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :first-child")).name).toBe('div');
7578
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :last-child")).name).toBe('wizard-navigation-bar');
76-
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar.bottom"))).toBeTruthy();
7779

7880
wizardTest.wizard.navBarLocation = "top";
7981
wizardTestFixture.detectChanges();
8082

8183
// navBar should be at the top of the wizard
8284
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar"))).toBeTruthy();
8385
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :first-child")).name).toBe('wizard-navigation-bar');
84-
expect(wizardTestFixture.debugElement.query(By.css(".nav-bar.top"))).toBeTruthy();
86+
expect(wizardTestFixture.debugElement.query(By.css(".wizard-centered > :last-child")).name).toBe('div');
8587
});
8688

8789
it('should have steps', () => {

0 commit comments

Comments
 (0)