Skip to content

Commit ceccf9b

Browse files
committed
- extended README to contain a npm version badge of this library
- extended README to contain installation instructions on how to install this library via npm - bumped dependency version to current versions - added two tests to read 100% coverage
1 parent 9d1c7c2 commit ceccf9b

File tree

4 files changed

+79
-37
lines changed

4 files changed

+79
-37
lines changed

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
# Overview ng2-wizard
1+
# Overview ng2-archwizard
22

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)
66
[![Dependency Licence Status](https://dependencyci.com/github/madoar/ng2-wizard/badge)](https://dependencyci.com/github/madoar/ng2-wizard)
77
[![Code Climate](https://codeclimate.com/github/madoar/ng2-wizard/badges/gpa.svg)](https://codeclimate.com/github/madoar/ng2-wizard)
88
[![Test Coverage](https://codeclimate.com/github/madoar/ng2-wizard/badges/coverage.svg)](https://codeclimate.com/github/madoar/ng2-wizard/coverage)
9+
[![NPM Version](https://img.shields.io/npm/v/ng2-archwizard.svg)](https://www.npmjs.com/package/ng2-archwizard)
910

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

@@ -17,6 +18,25 @@ Run `npm run build` to build the project. The build artifacts will be stored in
1718

1819
Run `npm test` to execute the unit tests via [Karma](https://karma-runner.github.io).
1920

21+
## Installation
22+
23+
Ng2-archwizard is available as an NPM package. To install ng2-archwizard in your project directory run:
24+
```
25+
$ npm install --save ng2-archwizard
26+
```
27+
28+
Afterwards you can import ng2-archwizard in your angular 2 project by adding the `WizardModule` to your Module declaration as followed:
29+
```typescript
30+
import {WizardModule} from "ng2-archwizard/dist";
31+
32+
@NgModule({
33+
imports: [
34+
WizardModule
35+
],
36+
})
37+
export class Module { }
38+
```
39+
2040
## How to use the wizard
2141

2242
To use the this wizard component in an angular 2 project simply add a wizard component to the html template of your component, like this:

package.json

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -31,68 +31,68 @@
3131
"build": "rimraf dist && ngc -p src/tsconfig.aot.json && gulp"
3232
},
3333
"dependencies": {
34-
"@angular/common": "^2.3.1",
35-
"@angular/compiler": "^2.3.1",
36-
"@angular/core": "^2.3.1",
37-
"@angular/http": "^2.3.1",
38-
"@angular/platform-browser": "^2.3.1",
39-
"@angular/platform-browser-dynamic": "^2.3.1",
40-
"@angular/router": "^3.3.1",
34+
"@angular/common": "^2.4.7",
35+
"@angular/compiler": "^2.4.7",
36+
"@angular/core": "^2.4.7",
37+
"@angular/http": "^2.4.7",
38+
"@angular/platform-browser": "^2.4.7",
39+
"@angular/platform-browser-dynamic": "^2.4.7",
40+
"@angular/router": "^3.4.7",
4141
"core-js": "^2.4.1",
42-
"rxjs": "^5.0.1",
42+
"rxjs": "^5.1.1",
4343
"ts-helpers": "^1.1.2",
44-
"zone.js": "^0.7.2"
44+
"zone.js": "^0.7.7"
4545
},
4646
"devDependencies": {
47-
"@angular/compiler-cli": "^2.3.1",
48-
"@angularclass/hmr": "^1.0.1",
47+
"@angular/compiler-cli": "^2.4.7",
48+
"@angularclass/hmr": "^1.2.2",
4949
"@angularclass/hmr-loader": "^3.0.2",
50-
"@ngtools/webpack": "^1.2.8",
51-
"@types/jasmine": "^2.2.29",
52-
"@types/node": "^6.0.38",
53-
"@types/selenium-webdriver": "2.53.33",
50+
"@ngtools/webpack": "^1.2.9",
51+
"@types/jasmine": "^2.5.42",
52+
"@types/node": "^7.0.5",
53+
"@types/selenium-webdriver": "2.53.39",
5454
"angular-router-loader": "^0.5.0",
55-
"angular2-template-loader": "^0.6.1",
56-
"autoprefixer": "^6.3.2",
55+
"angular2-template-loader": "^0.6.2",
56+
"autoprefixer": "^6.7.3",
5757
"awesome-typescript-loader": "^3.0.3",
58-
"codelyzer": "2.0.0-beta.4",
58+
"codelyzer": "2.0.0",
5959
"copy-webpack-plugin": "^4.0.0",
60-
"css-loader": "^0.25.0",
60+
"css-loader": "^0.26.1",
6161
"extract-text-webpack-plugin": "^2.0.0-beta.4",
62-
"file-loader": "^0.9.0",
62+
"file-loader": "^0.10.0",
6363
"gulp": "^3.9.1",
6464
"gulp-less": "^3.3.0",
6565
"html-loader": "^0.4.0",
66-
"html-webpack-plugin": "^2.8.1",
67-
"istanbul-instrumenter-loader": "^0.2.0",
68-
"jasmine-core": "^2.3.4",
66+
"html-webpack-plugin": "^2.28.0",
67+
"istanbul-instrumenter-loader": "^2.0.0",
68+
"jasmine-core": "^2.5.2",
6969
"jasmine-spec-reporter": "^2.7.0",
7070
"json-loader": "^0.5.3",
71-
"karma": "1.3.0",
71+
"karma": "1.4.1",
7272
"karma-chrome-launcher": "^2.0.0",
7373
"karma-coverage": "^1.0.0",
7474
"karma-jasmine": "^1.0.2",
7575
"karma-mocha-reporter": "^2.0.3",
7676
"karma-phantomjs-launcher": "^1.0.0",
7777
"karma-remap-coverage": "^0.1.4",
7878
"karma-sourcemap-loader": "^0.3.7",
79-
"karma-webpack": "1.8.0",
79+
"karma-webpack": "2.0.2",
8080
"less": "^2.7.1",
8181
"less-loader": "^2.2.3",
82-
"node-sass": "^3.4.2",
82+
"node-sass": "^4.5.0",
8383
"phantomjs-prebuilt": "^2.1.14",
84-
"postcss-loader": "^1.1.0",
85-
"protractor": "^4.0.10",
84+
"postcss-loader": "^1.3.0",
85+
"protractor": "^5.1.1",
8686
"raw-loader": "0.5.1",
8787
"reflect-metadata": "^0.1.9",
88-
"remap-istanbul": "^0.6.4",
88+
"remap-istanbul": "^0.9.1",
8989
"rimraf": "^2.5.1",
90-
"sass-loader": "^4.0.0",
90+
"sass-loader": "^6.0.0",
9191
"style-loader": "^0.13.0",
9292
"to-string-loader": "^1.1.5",
9393
"tslint": "^4.4.2",
94-
"tslint-loader": "^3.3.0",
95-
"typescript": "2.1.5",
94+
"tslint-loader": "^3.4.2",
95+
"typescript": "2.1.6",
9696
"url-loader": "^0.5.6",
9797
"webpack": "^2.2.0",
9898
"webpack-dev-server": "2.3.0",

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,11 @@ describe('WizardStepComponent', () => {
104104

105105
expect(wizardTest.eventLog).toEqual(['enter Forwards 1', 'exit Forwards 1', 'enter Forwards 3', 'exit Backwards 3', 'enter Backwards 2']);
106106
});
107+
108+
it('should stay at first step correctly', () => {
109+
wizardTest.wizard.goToStep(0);
110+
wizardTestFixture.detectChanges();
111+
112+
expect(wizardTest.eventLog).toEqual(['enter Forwards 1', 'exit Stay 1', 'enter Stay 1']);
113+
});
107114
});

src/components/directives/go-to-step.directive.spec.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {OptionalStepDirective} from "./optional-step.directive";
1616
<wizard>
1717
<wizard-step title='Steptitle 1'>
1818
Step 1
19+
<button type="button" goToStep="0" (finalize)="finalizeStep(1)">Stay at this step</button>
1920
<button type="button" goToStep="1" (finalize)="finalizeStep(1)">Go to second step</button>
2021
<button type="button" goToStep="2" (finalize)="finalizeStep(1)">Go to third step</button>
2122
</wizard-step>
@@ -60,13 +61,14 @@ describe('GoToStepDirective', () => {
6061
it('should create an instance', () => {
6162
expect(wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:first-child'))).toBeTruthy();
6263
expect(wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(2)'))).toBeTruthy();
64+
expect(wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(3)'))).toBeTruthy();
6365
expect(wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 2"] > button[goToStep]'))).toBeTruthy();
6466
expect(wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 3"] > button[goToStep]'))).toBeTruthy();
65-
expect(wizardTestFixture.debugElement.queryAll(By.css('wizard-step > button[goToStep]')).length).toBe(4);
67+
expect(wizardTestFixture.debugElement.queryAll(By.css('wizard-step > button[goToStep]')).length).toBe(5);
6668
});
6769

6870
it('should move to step correctly', () => {
69-
const firstStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:first-child')).nativeElement;
71+
const firstStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(2)')).nativeElement;
7072
const secondStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 2"] > button[goToStep]')).nativeElement;
7173

7274
expect(wizardTest.wizard.currentStepIndex).toBe(0);
@@ -88,7 +90,7 @@ describe('GoToStepDirective', () => {
8890
});
8991

9092
it('should jump over an optional step correctly', () => {
91-
const firstStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(2)')).nativeElement;
93+
const firstStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(3)')).nativeElement;
9294
const thirdStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 3"] > button[goToStep]')).nativeElement;
9395

9496
expect(wizardTest.wizard.currentStepIndex).toBe(0);
@@ -109,9 +111,22 @@ describe('GoToStepDirective', () => {
109111
expect(wizardTestFixture.debugElement.query(By.css('wizard-step.current')).nativeElement.title).toBe("Steptitle 1");
110112
});
111113

114+
it('should stay at current step correctly', () => {
115+
const firstStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(1)')).nativeElement;
116+
117+
expect(wizardTest.wizard.currentStepIndex).toBe(0);
118+
expect(wizardTestFixture.debugElement.query(By.css('wizard-step.current')).nativeElement.title).toBe("Steptitle 1");
119+
120+
// click button
121+
firstStepGoToButton.click();
122+
wizardTestFixture.detectChanges();
123+
124+
expect(wizardTest.wizard.currentStepIndex).toBe(0);
125+
expect(wizardTestFixture.debugElement.query(By.css('wizard-step.current')).nativeElement.title).toBe("Steptitle 1");
126+
});
112127

113128
it('should finalize step correctly', () => {
114-
const firstStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(2)')).nativeElement;
129+
const firstStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 1"] > button[goToStep]:nth-child(3)')).nativeElement;
115130
const thirdStepGoToButton = wizardTestFixture.debugElement.query(By.css('wizard-step[title="Steptitle 3"] > button[goToStep]')).nativeElement;
116131

117132
expect(wizardTest.wizard.currentStepIndex).toBe(0);

0 commit comments

Comments
 (0)