Skip to content

Commit 69274ac

Browse files
committed
Merge branch 'release/5.0.1'
2 parents 102714d + fbc8896 commit 69274ac

31 files changed

+1016
-1199
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ npm-debug.log*
44
yarn-error.log
55
/dist
66
/test/*coverage
7+
/test/coverage*
78
/.chrome
89

910
# Logs #

README.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ From the project folder, execute the following commands:
1212
npm install # or: yarn install
1313
```
1414

15-
Don't forget to install the typings:
16-
```shell
17-
npm run install:typings
18-
```
19-
2015
This will install all required dependencies, including a local version of Webpack that is going to
2116
build and bundle the app. There is no need to install Webpack globally.
2217

@@ -67,13 +62,26 @@ This skeleton provides three frameworks for running tests.
6762

6863
You can choose one or two and remove the other, or even use all of them for different types of tests.
6964

70-
### Jest
65+
By default, both Jest and Karma are configured to run the same tests with Jest's matchers (see Jest documentation for more information).
66+
67+
If you wish to only run certain tests under one of the runners, wrap them in an `if`, like this:
68+
69+
```js
70+
if (jest) {
71+
// since only jest supports creating snapshot:
72+
it('should render correctly', () => {
73+
expect(document.body.outerHTML).toMatchSnapshot();
74+
});
75+
}
76+
```
77+
78+
### Jest + Jasmine 2
7179

7280
Jest is a powerful unit testing runner and framework.
7381
It runs really fast, however the tests are run under NodeJS, not the browser.
7482
This means there might be some cases where something you'd expect works in reality, but fails in a test. One of those things will be SVG, which isn't supported under NodeJS. However, the framework is perfect for doing unit tests of pure functions, and works pretty well in combination with `aurelia-testing`.
7583

76-
To create new Jest tests, create files with the extension `.test.ts`, either in the `src` directory or in the `test/jest-unit` directory.
84+
To create new Jest tests, create files with the extension `.spec.ts`, either in the `src` directory or in the `test/unit` directory.
7785

7886
To run the Jest unit tests, run:
7987

@@ -87,11 +95,13 @@ To run the Jest watcher (re-runs tests on changes), run:
8795
npm start -- test.jest.watch
8896
```
8997

90-
### Karma + Jasmine
98+
### Karma + Jasmine 2
99+
100+
Karma is also a powerful test runner, which by default runs in the browser. This means that whatever works in real browsers, should also work the same way in the unit tests. But it also means the framework is heavier to execute and not as lean to work with.
91101

92-
Karma is also a powerful test runner, and combined with Jasmine it can be a pleasure to work with. Karma always runs in the browser. This means that whatever works in real browsers, should also work the same way in the unit tests. But it also means the framework is heavier to execute and not as lean to work with.
102+
To ease transitioning between Jest and Karma, Jasmine 2 is configured with Jest's matchers.
93103

94-
To create new Karma tests, create files with the extension `.spec.ts`, either in the `src` directory or in the `test/karma-unit` directory.
104+
To create new Karma tests, create files with the extension `.spec.ts`, either in the `src` directory or in the `test/unit` directory.
95105

96106
To run the Karma unit tests, run:
97107

package-scripts.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@ module.exports = {
77
test: {
88
default: 'nps test.jest',
99
jest: {
10-
default: 'jest',
10+
default: series(
11+
rimraf('test/coverage-jest'),
12+
'jest'
13+
),
1114
watch: 'jest --watch',
1215
},
1316
karma: {
1417
default: series(
15-
rimraf('test/karma-coverage'),
18+
rimraf('test/coverage-karma'),
1619
'karma start test/karma.conf.js'
1720
),
18-
watch: 'karma start test/karma.conf.js --single-run=false',
19-
debug: 'karma start test/karma.conf.js --single-run=false --debug'
21+
watch: 'karma start test/karma.conf.js --no-single-run',
22+
debug: 'karma start test/karma.conf.js --no-single-run --debug'
2023
},
2124
all: concurrent({
2225
browser: series.nps('test.karma', 'e2e'),
@@ -85,7 +88,7 @@ module.exports = {
8588
hmr: `webpack-dev-server -d --devtool '#source-map' --inline --hot --env.server`
8689
},
8790
},
88-
serve: 'http-server dist --cors',
91+
serve: 'http-server dist --cors --gzip',
8992
mobile: {
9093
default: 'nps mobile.build',
9194
link: 'node ./scripts/mobile-link.js',

package.json

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aurelia-typescript-boilerplate",
3-
"version": "5.0.0",
3+
"version": "5.0.1",
44
"title": "Aurelia Typescript Boilerplate",
55
"description": "A starter kit for building a standard navigation-style app with Aurelia and Webpack.",
66
"main": "dist/app.bundle.js",
@@ -52,86 +52,105 @@
5252
"transform": {
5353
"^.+\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
5454
},
55-
"testRegex": "\\.test\\.(ts|js)x?$",
55+
"testRegex": "\\.spec\\.(ts|js)x?$",
5656
"setupFiles": [
5757
"<rootDir>/test/jest-pretest.ts"
5858
],
5959
"testEnvironment": "node",
6060
"moduleNameMapper": {
6161
"aurelia-(.*)": "<rootDir>/node_modules/$1"
62-
}
62+
},
63+
"collectCoverage": true,
64+
"collectCoverageFrom": [
65+
"src/**/*.{js,ts}",
66+
"!**/*.spec.{js,ts}",
67+
"!**/node_modules/**",
68+
"!**/test/**"
69+
],
70+
"coverageDirectory": "<rootDir>/test/coverage-jest",
71+
"coverageReporters": [
72+
"json",
73+
"lcov",
74+
"text",
75+
"html"
76+
],
77+
"mapCoverage": true
6378
},
6479
"devDependencies": {
65-
"@types/jest": "^19.2.2",
66-
"@types/lodash": "^4.14.62",
67-
"@types/node": "^7.0.12",
68-
"@types/webpack": "^2.2.14",
80+
"@types/jest": "^19.2.3",
81+
"@types/lodash": "^4.14.64",
82+
"@types/node": "^7.0.21",
83+
"@types/webpack": "^2.2.15",
6984
"aurelia-loader-nodejs": "^1.0.1",
7085
"aurelia-pal-nodejs": "1.0.0-beta.1.0.0",
71-
"aurelia-protractor-plugin": "^1.0.2",
86+
"aurelia-protractor-plugin": "^1.0.3",
7287
"aurelia-template-lint-webpack-loader": "^1.0.3",
7388
"aurelia-testing": "^1.0.0-beta.3.0.1",
7489
"aurelia-webpack-plugin": "^2.0.0-rc.2",
75-
"autoprefixer": "^6.7.7",
76-
"awesome-typescript-loader": "^3.1.2",
90+
"autoprefixer": "^7.1.1",
91+
"awesome-typescript-loader": "^3.1.3",
92+
"case-sensitive-paths-webpack-plugin": "^2.0.0",
7793
"chalk": "^1.1.3",
7894
"compression-webpack-plugin": "^0.4.0",
7995
"copy-webpack-plugin": "^4.0.1",
80-
"cordova": "^6.5.0",
81-
"cross-env": "^4.0.0",
82-
"css-loader": "^0.28.0",
96+
"cordova": "^7.0.1",
97+
"cross-env": "^5.0.0",
98+
"css-loader": "^0.28.1",
8399
"expose-loader": "^0.7.3",
84100
"extract-text-webpack-plugin": "^2.1.0",
85101
"favicons-webpack-plugin": "^0.0.7",
86102
"file-loader": "^0.11.1",
87103
"html-webpack-plugin": "^2.28.0",
88-
"http-server": "^0.9.0",
104+
"http-server": "^0.10.0",
89105
"img-loader": "^2.0.0",
90106
"istanbul-instrumenter-loader": "^2.0.0",
91-
"jasmine-core": "^2.5.2",
92-
"jest": "^19.0.2",
107+
"jasmine-core": "^2.6.2",
108+
"jest": "^20.0.3",
109+
"jest-cli": "^20.0.3",
93110
"json-loader": "^0.5.4",
94-
"karma": "^1.3.0",
95-
"karma-chrome-launcher": "^2.0.0",
96-
"karma-coverage-istanbul-reporter": "^1.1.0",
97-
"karma-jasmine": "^1.0.2",
98-
"karma-mocha-reporter": "^2.2.0",
111+
"karma": "^1.7.0",
112+
"karma-chrome-launcher": "^2.1.1",
113+
"karma-coverage-istanbul-reporter": "^1.2.1",
114+
"karma-jasmine": "^1.1.0",
115+
"karma-mocha-reporter": "^2.2.3",
99116
"karma-webpack": "^2.0.3",
100117
"loader-utils": "^1.1.0",
101118
"ncp": "^2.0.0",
102-
"node-sass": "^4.5.2",
103-
"nps": "^5.0.5",
119+
"node-sass": "^4.5.3",
120+
"nps": "^5.2.0",
104121
"nps-utils": "^1.2.0",
105-
"postcss-loader": "^1.3.3",
106-
"protractor": "^5.1.1",
107-
"sass-loader": "^6.0.3",
108-
"style-loader": "^0.16.1",
109-
"ts-jest": "^19.0.8",
110-
"ts-node": "^3.0.2",
111-
"tslint": "^5.1.0",
112-
"tslint-loader": "^3.5.2",
113-
"typescript": "^2.2.2",
122+
"postcss-loader": "^2.0.5",
123+
"protractor": "^5.1.2",
124+
"sass-loader": "^6.0.5",
125+
"style-loader": "^0.17.0",
126+
"ts-jest": "^20.0.4",
127+
"ts-node": "^3.0.4",
128+
"tslib": "^1.7.1",
129+
"tslint": "^5.2.0",
130+
"tslint-loader": "^3.5.3",
131+
"typescript": "^2.3.2",
114132
"typings": "^2.1.1",
115133
"url-loader": "^0.5.8",
116134
"wait-on": "^2.0.2",
117-
"webpack": "^2.3.3",
118-
"webpack-dev-server": "^2.4.2",
135+
"webpack": "^2.5.1",
136+
"webpack-dev-server": "^2.4.5",
119137
"webpack-notifier": "^1.5.0"
120138
},
121139
"dependencies": {
122140
"animate.css": "^3.5.2",
123141
"aurelia-animator-css": "^1.0.2",
124142
"aurelia-bootstrapper": "^2.1.1",
143+
"aurelia-dialog": "^1.0.0-rc.1.0.3",
125144
"aurelia-fetch-client": "^1.1.2",
126145
"aurelia-framework": "^1.1.2",
127146
"aurelia-history-browser": "^1.0.0",
128-
"aurelia-i18n": "^1.5.0",
147+
"aurelia-i18n": "^1.6.0",
129148
"aurelia-loader-webpack": "^2.1.0",
130149
"aurelia-logging-console": "^1.0.0",
131150
"aurelia-pal-browser": "^1.2.1",
132151
"aurelia-polyfills": "^1.2.1",
133152
"aurelia-router": "^1.3.0",
134-
"aurelia-templating": "^1.4.1",
153+
"aurelia-templating": "^1.4.2",
135154
"aurelia-templating-binding": "^1.3.0",
136155
"aurelia-templating-resources": "^1.4.0",
137156
"aurelia-templating-router": "^1.1.0",

src/app/app.vm.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ export class AppViewModel {
4646
{
4747
route: ['', 'welcome'],
4848
name: 'welcome',
49-
moduleId: PLATFORM.moduleName('./modules/welcome/welcome.vm'),
49+
moduleId: PLATFORM.moduleName('./modules/welcome/welcome.vm', 'welcome'),
5050
nav: true,
5151
title: 'Welcome'
5252
},
5353
{
5454
route: 'users',
5555
name: 'users',
56-
moduleId: PLATFORM.moduleName('./modules/users/users.vm'),
56+
moduleId: PLATFORM.moduleName('./modules/users/users.vm', 'users'),
5757
nav: true,
5858
title: 'Github Users'
5959
},
6060
{
6161
route: 'child-router',
6262
name: 'child-router',
63-
moduleId: PLATFORM.moduleName('./modules/child-router/child-router.vm'),
63+
moduleId: PLATFORM.moduleName('./modules/child-router/child-router.vm', 'child-router'),
6464
nav: true,
6565
title: 'Child Router'
6666
}

src/app/main.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-

1+
/// <reference types="aurelia-loader-webpack/src/webpack-hot-interface"/>
22
/**
33
* Import the main sass file for all the styles
44
*/
@@ -87,6 +87,13 @@ export async function configure(aurelia: Aurelia): Promise<void> {
8787
.plugin(PLATFORM.moduleName('aurelia-animator-css'))
8888
// if the css animator is enabled, add swap-order="after" to all router-view elements
8989

90+
.plugin(PLATFORM.moduleName('aurelia-dialog'), config => {
91+
config.useDefaults();
92+
config.settings.startingZIndex = 1005;
93+
config.settings.lock = true;
94+
config.settings.centerHorizontalOnly = false;
95+
})
96+
9097
// Anyone wanting to use HTMLImports to load views, will need to install the following plugin.
9198
// .plugin('aurelia-html-import-template-loader')
9299
/**

src/app/modules/welcome/welcome.vm.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,8 @@ <h3>Converter utility</h3>
3939
<h3>Validation</h3>
4040
<p>Validation is: ${validationValid}</p>
4141
<button class="btn btn-primary" click.delegate="validateFirstName()">validate</button>
42+
43+
<h3>Dialog</h3>
44+
<button click.delegate="openDialog()" class="btn btn-primary">open dialog</button>
4245
</section>
4346
</template>

src/app/modules/welcome/welcome.vm.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { autoinject } from 'aurelia-framework';
22
import { ValidationControllerFactory, ValidationController, validateTrigger, ValidationRules } from 'aurelia-validation';
3+
import { DialogService } from 'aurelia-dialog';
34

45
import { LogManager, Logger} from './../../services/logger.service';
56
import { AppConfigService } from './../../services/app-config.service';
67
import { LanguageService } from './../../services/language.service';
8+
import { EditPersonCustomElement } from './../../resources/elements/edit-person/edit-person.element';
79

810
@autoinject
911
export class WelcomeViewModel {
@@ -21,6 +23,7 @@ export class WelcomeViewModel {
2123
constructor(
2224
private appConfigService: AppConfigService,
2325
private languageService: LanguageService,
26+
private dialogService: DialogService,
2427
validationControllerFactory: ValidationControllerFactory
2528
) {
2629
this.logger = LogManager.getLogger('Welcome VM');
@@ -50,6 +53,17 @@ export class WelcomeViewModel {
5053
.then(r => this.validationValid = r.valid);
5154
}
5255

56+
public openDialog(): void {
57+
const person = { firstName: 'Wade', middleName: 'Owen', lastName: 'Watts' };
58+
this.dialogService.open({ viewModel: EditPersonCustomElement, model: person}).whenClosed(response => {
59+
if (!response.wasCancelled) {
60+
this.logger.info('Dialog not cancled', response);
61+
} else {
62+
this.logger.info('Dialog cancled', response);
63+
}
64+
});
65+
}
66+
5367
//Getters can't be directly observed, so they must be dirty checked.
5468
//However, if you tell Aurelia the dependencies, it no longer needs to dirty check the property.
5569
//To optimize by declaring the properties that this getter is computed from, uncomment the line below
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<template>
2+
<ux-dialog>
3+
<ux-dialog-body>
4+
<h2>Edit first name</h2>
5+
<input value.bind="person.firstName" />
6+
</ux-dialog-body>
7+
8+
<ux-dialog-footer>
9+
<button click.trigger="dialogController.cancel()">Cancel</button>
10+
<button click.trigger="dialogController.ok(person)">Ok</button>
11+
</ux-dialog-footer>
12+
</ux-dialog>
13+
</template>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { autoinject } from 'aurelia-framework';
2+
import {DialogController} from 'aurelia-dialog';
3+
4+
@autoinject
5+
export class EditPersonCustomElement {
6+
7+
public person = { firstName: '' };
8+
9+
constructor(
10+
public dialogController: DialogController
11+
) { }
12+
13+
public activate(person): void {
14+
this.person = person;
15+
}
16+
}

0 commit comments

Comments
 (0)