Skip to content

Commit 9a6e91b

Browse files
Merge pull request #17 from angular-redux/chore/updates
Update to latest CLI.
2 parents 4273c54 + 7d906b8 commit 9a6e91b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1593
-1942
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
23
"project": {
3-
"version": "1.0.0-beta.24",
4-
"name": "zoo"
4+
"name": "example-app"
55
},
66
"apps": [
77
{
@@ -13,47 +13,45 @@
1313
],
1414
"index": "index.html",
1515
"main": "main.ts",
16+
"polyfills": "polyfills.ts",
1617
"test": "test.ts",
17-
"tsconfig": "tsconfig.json",
18+
"tsconfig": "tsconfig.app.json",
19+
"testTsconfig": "tsconfig.spec.json",
1820
"prefix": "app",
19-
"mobile": false,
2021
"styles": [
2122
"styles.css"
2223
],
2324
"scripts": [],
25+
"environmentSource": "environments/environment.ts",
2426
"environments": {
25-
"source": "environments/environment.ts",
2627
"dev": "environments/environment.ts",
2728
"prod": "environments/environment.prod.ts"
2829
}
2930
}
3031
],
31-
"addons": [],
32-
"packages": [],
3332
"e2e": {
3433
"protractor": {
3534
"config": "./protractor.conf.js"
3635
}
3736
},
37+
"lint": [
38+
{
39+
"project": "src/tsconfig.app.json"
40+
},
41+
{
42+
"project": "src/tsconfig.spec.json"
43+
},
44+
{
45+
"project": "e2e/tsconfig.e2e.json"
46+
}
47+
],
3848
"test": {
3949
"karma": {
4050
"config": "./karma.conf.js"
4151
}
4252
},
4353
"defaults": {
4454
"styleExt": "css",
45-
"prefixInterfaces": false,
46-
"inline": {
47-
"style": false,
48-
"template": false
49-
},
50-
"spec": {
51-
"class": false,
52-
"component": true,
53-
"directive": true,
54-
"module": false,
55-
"pipe": true,
56-
"service": true
57-
}
55+
"component": {}
5856
}
5957
}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
.c9/
1515
*.launch
1616
.settings/
17+
*.sublime-workspace
1718

1819
# IDE - VSCode
1920
.vscode/*

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ application.
1010
* [@angular-redux/form](https://github.com/angular-redux/form) Time travel with Angular forms
1111
* [Redux DevTools Chrome Extension](https://github.com/zalmoxisus/redux-devtools-extension)
1212

13-
This project was generated with [angular-cli](https://github.com/angular/angular-cli) version 1.0.0-beta.24.
13+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.0.0-rc.0.
1414

1515
## Development server
1616
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
1717

18+
## Code scaffolding
19+
20+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive/pipe/service/class/module`.
21+
1822
## Build
1923

2024
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
@@ -27,3 +31,7 @@ Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.
2731

2832
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
2933
Before running the tests make sure you are serving the app via `ng serve`.
34+
35+
## Further help
36+
37+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

e2e/app.e2e-spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { ZooPage } from './app.po';
1+
import { AppPage } from './app.po';
22

3-
describe('zoo App', function() {
4-
let page: ZooPage;
3+
describe('Zoo Animals App', () => {
4+
let page: AppPage;
55

66
beforeEach(() => {
7-
page = new ZooPage();
7+
page = new AppPage();
88
});
99

10-
it('should display message saying app works', () => {
10+
it('should display message saying "Welcome to the Zoo"', () => {
1111
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('app works!');
12+
expect(page.getParagraphText()).toEqual('Welcome to the Zoo');
1313
});
1414
});

e2e/app.po.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { browser, element, by } from 'protractor';
22

3-
export class ZooPage {
3+
export class AppPage {
44
navigateTo() {
55
return browser.get('/');
66
}
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
{
2-
"compileOnSave": false,
32
"compilerOptions": {
3+
"sourceMap": true,
44
"declaration": false,
5+
"moduleResolution": "node",
56
"emitDecoratorMetadata": true,
67
"experimentalDecorators": true,
7-
"module": "commonjs",
8-
"moduleResolution": "node",
8+
"lib": [
9+
"es2016"
10+
],
911
"outDir": "../dist/out-tsc-e2e",
10-
"sourceMap": true,
11-
"target": "es5",
12-
"typeRoots": [
13-
"../node_modules/@types"
12+
"module": "commonjs",
13+
"target": "es6",
14+
"types":[
15+
"jasmine",
16+
"node"
1417
]
1518
}
1619
}

karma.conf.js

+13-12
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,36 @@
44
module.exports = function (config) {
55
config.set({
66
basePath: '',
7-
frameworks: ['jasmine', 'angular-cli'],
7+
frameworks: ['jasmine', '@angular/cli'],
88
plugins: [
99
require('karma-jasmine'),
1010
require('karma-chrome-launcher'),
11-
require('karma-remap-istanbul'),
12-
require('angular-cli/plugins/karma')
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage-istanbul-reporter'),
13+
require('@angular/cli/plugins/karma')
1314
],
15+
client:{
16+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
1418
files: [
1519
{ pattern: './src/test.ts', watched: false }
1620
],
1721
preprocessors: {
18-
'./src/test.ts': ['angular-cli']
22+
'./src/test.ts': ['@angular/cli']
1923
},
2024
mime: {
2125
'text/x-typescript': ['ts','tsx']
2226
},
23-
remapIstanbulReporter: {
24-
reports: {
25-
html: 'coverage',
26-
lcovonly: './coverage/coverage.lcov'
27-
}
27+
coverageIstanbulReporter: {
28+
reports: [ 'html', 'lcovonly' ],
29+
fixWebpackSourcePaths: true
2830
},
2931
angularCli: {
30-
config: './angular-cli.json',
3132
environment: 'dev'
3233
},
3334
reporters: config.angularCli && config.angularCli.codeCoverage
34-
? ['progress', 'karma-remap-istanbul']
35-
: ['progress'],
35+
? ['progress', 'coverage-istanbul']
36+
: ['progress', 'kjhtml'],
3637
port: 9876,
3738
colors: true,
3839
logLevel: config.LOG_INFO,

package.json

+32-33
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,53 @@
11
{
2-
"name": "zoo",
2+
"name": "example-app",
33
"version": "0.0.0",
44
"license": "MIT",
5-
"angular-cli": {},
65
"scripts": {
76
"ng": "ng",
87
"start": "ng serve",
9-
"lint": "tslint \"src/**/*.ts\"",
8+
"build": "ng build",
109
"test": "ng test",
11-
"pree2e": "webdriver-manager update --standalone false --gecko false",
12-
"e2e": "protractor"
10+
"lint": "ng lint",
11+
"e2e": "ng e2e"
1312
},
1413
"private": true,
1514
"dependencies": {
1615
"@angular-redux/form": "^6.0.1",
1716
"@angular-redux/router": "^6.0.1",
18-
"@angular-redux/store": "^6.0.0",
19-
"@angular/common": "^2.3.1",
20-
"@angular/compiler": "^2.3.1",
21-
"@angular/core": "^2.3.1",
22-
"@angular/forms": "^2.3.1",
23-
"@angular/http": "^2.3.1",
24-
"@angular/platform-browser": "^2.3.1",
25-
"@angular/platform-browser-dynamic": "^2.3.1",
26-
"@angular/router": "^3.3.1",
17+
"@angular-redux/store": "^6.0.1",
18+
"@angular/common": "^2.4.0",
19+
"@angular/compiler": "^2.4.0",
20+
"@angular/core": "^2.4.0",
21+
"@angular/forms": "^2.4.0",
22+
"@angular/http": "^2.4.0",
23+
"@angular/platform-browser": "^2.4.0",
24+
"@angular/platform-browser-dynamic": "^2.4.0",
25+
"@angular/router": "^3.4.0",
2726
"core-js": "^2.4.1",
2827
"redux": "^3.6.0",
2928
"redux-logger": "^2.8.1",
30-
"redux-observable": "^0.12.2",
31-
"rxjs": "^5.0.1",
32-
"ts-helpers": "^1.1.1",
33-
"zone.js": "^0.7.2"
29+
"redux-observable": "^0.13.0",
30+
"rxjs": "^5.1.0",
31+
"zone.js": "^0.7.6"
3432
},
3533
"devDependencies": {
36-
"@angular/compiler-cli": "^2.3.1",
34+
"@angular/cli": "1.0.0-rc.0",
35+
"@angular/compiler-cli": "^2.4.0",
3736
"@types/jasmine": "2.5.38",
38-
"@types/node": "^6.0.42",
37+
"@types/node": "~6.0.60",
3938
"@types/redux-logger": "^2.6.34",
40-
"angular-cli": "1.0.0-beta.24",
41-
"codelyzer": "~2.0.0-beta.1",
42-
"jasmine-core": "2.5.2",
43-
"jasmine-spec-reporter": "2.5.0",
44-
"karma": "1.2.0",
45-
"karma-chrome-launcher": "^2.0.0",
46-
"karma-cli": "^1.0.1",
47-
"karma-jasmine": "^1.0.2",
48-
"karma-remap-istanbul": "^0.2.1",
49-
"protractor": "~4.0.13",
50-
"ts-node": "1.2.1",
51-
"tslint": "^4.0.2",
52-
"typescript": "~2.0.3"
39+
"codelyzer": "~2.0.0",
40+
"jasmine-core": "~2.5.2",
41+
"jasmine-spec-reporter": "~3.2.0",
42+
"karma": "~1.4.1",
43+
"karma-chrome-launcher": "~2.0.0",
44+
"karma-cli": "~1.0.1",
45+
"karma-coverage-istanbul-reporter": "^0.2.0",
46+
"karma-jasmine": "~1.1.0",
47+
"karma-jasmine-html-reporter": "^0.2.2",
48+
"protractor": "~5.1.0",
49+
"ts-node": "~2.0.0",
50+
"tslint": "~4.4.2",
51+
"typescript": "~2.0.0"
5352
}
5453
}

protractor.conf.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Protractor configuration file, see link for more information
22
// https://github.com/angular/protractor/blob/master/lib/config.ts
33

4-
/*global jasmine */
5-
var SpecReporter = require('jasmine-spec-reporter');
4+
const { SpecReporter } = require('jasmine-spec-reporter');
65

76
exports.config = {
87
allScriptsTimeout: 11000,
@@ -20,13 +19,12 @@ exports.config = {
2019
defaultTimeoutInterval: 30000,
2120
print: function() {}
2221
},
23-
useAllAngular2AppRoots: true,
2422
beforeLaunch: function() {
2523
require('ts-node').register({
26-
project: 'e2e'
24+
project: 'e2e/tsconfig.e2e.json'
2725
});
2826
},
29-
onPrepare: function() {
30-
jasmine.getEnv().addReporter(new SpecReporter());
27+
onPrepare() {
28+
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
3129
}
3230
};

src/app/app.component.spec.ts

+29-21
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
1-
/* tslint:disable:no-unused-variable */
2-
31
import { TestBed, async } from '@angular/core/testing';
2+
import { RouterTestingModule } from '@angular/router/testing';
3+
import { NgRedux, DevToolsExtension } from '@angular-redux/store';
44
import { AppComponent } from './app.component';
5+
import { AppActions } from './app.actions';
6+
7+
// I follow a minimal mocking approach:
8+
// Mock all dependencies with empty objects
9+
// and let each test specify the exact stub
10+
// or spy behaviour that it needs. This keeps
11+
// mocks simple and tests decoupled as they
12+
// should be.
13+
const mockRedux = {
14+
dispatch: function() {},
15+
};
16+
const mockDevTools = {};
517

618
describe('AppComponent', () => {
7-
beforeEach(() => {
19+
beforeEach(async(() => {
820
TestBed.configureTestingModule({
9-
declarations: [
10-
AppComponent
21+
declarations: [AppComponent],
22+
imports: [ RouterTestingModule ],
23+
providers: [
24+
{ provide: NgRedux, useValue: mockRedux },
25+
{ provide: DevToolsExtension, useValue: mockDevTools },
26+
AppActions,
1127
],
12-
});
13-
TestBed.compileComponents();
14-
});
28+
}).compileComponents();
29+
}));
1530

1631
it('should create the app', async(() => {
17-
let fixture = TestBed.createComponent(AppComponent);
18-
let app = fixture.debugElement.componentInstance;
32+
const fixture = TestBed.createComponent(AppComponent);
33+
const app = fixture.debugElement.componentInstance;
1934
expect(app).toBeTruthy();
2035
}));
2136

22-
it(`should have as title 'app works!'`, async(() => {
23-
let fixture = TestBed.createComponent(AppComponent);
24-
let app = fixture.debugElement.componentInstance;
25-
expect(app.title).toEqual('app works!');
26-
}));
27-
28-
it('should render title in a h1 tag', async(() => {
29-
let fixture = TestBed.createComponent(AppComponent);
30-
fixture.detectChanges();
31-
let compiled = fixture.debugElement.nativeElement;
32-
expect(compiled.querySelector('h1').textContent).toContain('app works!');
37+
it(`should have as title 'Welcome to the Zoo'`, async(() => {
38+
const fixture = TestBed.createComponent(AppComponent);
39+
const app = fixture.debugElement.componentInstance;
40+
expect(app.title).toEqual('Welcome to the Zoo');
3341
}));
3442
});

0 commit comments

Comments
 (0)