Skip to content

Commit 3f5c510

Browse files
committed
Add spec runner for Knockout 3.4.1 and 3.4.2
1 parent 80b85e5 commit 3f5c510

22 files changed

+5789
-4246
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ end_of_line = lf
55
insert_final_newline = true
66
trim_trailing_whitespace = true
77
indent_style = space
8-
indent_size = 4
8+
indent_size = 2
99

1010
[*.md]
1111
trim_trailing_whitespace = false

.gitattributes

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
* text eol=lf
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
language: node_js
22
node_js:
3-
- "node"
3+
- node
4+
- '8'
5+
- '6.9.5'
46
sudo: false
5-
script: "npm test"

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Official documentation [here](http://knockoutjs.com/documentation/plugins-mappin
1717
#### Bower
1818

1919
```sh
20-
bower install bower-knockout-mapping --save-dev
20+
bower install bower-knockout-mapping --save
2121
```
2222

2323
#### NPM
@@ -63,13 +63,12 @@ var newData = ko.mapping.toJS(viewModel);
6363

6464
```
6565

66-
Run this example in [JSFiddle](http://jsfiddle.net/wmeqx7ss/141/).
66+
Run this example in [JSFiddle](http://jsfiddle.net/wmeqx7ss/280/).
6767

6868

6969
## Test
7070

71-
Continuous Integration tests are done with Travis, and the associated Gulp task is `test-ci`.
72-
For development `test` task is used, which runs the tests against the latest version of Knockout.
71+
Unless `CI` environment variable is defined, the tests use the latest version Knockout.
7372

7473

7574
## License

gulpfile.js

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,50 @@ var header = require('gulp-header');
1313
var sourceMaps = require('gulp-sourcemaps');
1414

1515
var buildConfig = {
16-
outputPath: 'dist',
17-
pkg: require('./package.json'),
18-
banner: [
19-
'/*!',
20-
' * Knockout Mapping plugin v<%= pkg.version %>',
21-
' * (c) 2013 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/',
22-
' * License: MIT (http://www.opensource.org/licenses/mit-license.php)',
23-
' */\n'
24-
].join('\n')
16+
outputPath: 'dist',
17+
pkg: require('./package.json'),
18+
banner: [
19+
'/*!',
20+
' * Knockout Mapping plugin v<%= pkg.version %>',
21+
' * (c) 2013 Steven Sanderson, Roy Jacobs - http://knockoutjs.com/',
22+
' * License: MIT (http://www.opensource.org/licenses/mit-license.php)',
23+
' */\n'
24+
].join('\n')
2525
};
2626

2727

28-
gulp.task('clear', function() {
29-
del.sync('*', {cwd: 'dist'});
28+
gulp.task('clear', function () {
29+
return del('*', {cwd: 'dist'});
3030
});
3131

32-
gulp.task('build', function() {
33-
return gulp.src('knockout.mapping.js')
34-
.pipe(plumber())
35-
.pipe(jshint())
36-
.pipe(jshint.reporter('jshint-stylish'))
37-
.pipe(header(buildConfig.banner, {pkg: buildConfig.pkg}))
38-
.pipe(gulp.dest(buildConfig.outputPath))
39-
.pipe(rename('knockout.mapping.min.js'))
40-
.pipe(replace(/(:?var\s*?DEBUG\s*?=\s*?true)/, 'const DEBUG=false'))
41-
.pipe(sourceMaps.init())
42-
.pipe(uglify({preserveComments: 'some'}))
43-
.pipe(sourceMaps.write('./'))
44-
.pipe(gulp.dest(buildConfig.outputPath));
32+
gulp.task('build', function () {
33+
return gulp.src('knockout.mapping.js')
34+
.pipe(plumber({errorHandler: process.env.NODE_ENV === 'development'}))
35+
.pipe(jshint()).pipe(jshint.reporter('jshint-stylish'))
36+
.pipe(header(buildConfig.banner, {pkg: buildConfig.pkg}))
37+
.pipe(gulp.dest(buildConfig.outputPath))
38+
.pipe(rename('knockout.mapping.min.js'))
39+
.pipe(replace(/(:?var\s*?DEBUG\s*?=\s*?true)/, 'var DEBUG=false'))
40+
.pipe(sourceMaps.init())
41+
.pipe(uglify())
42+
.pipe(sourceMaps.write('./'))
43+
.pipe(gulp.dest(buildConfig.outputPath));
4544
});
4645

47-
gulp.task('test', ['test-jshint'], function() {
48-
return gulp.src('spec/spec-runner.htm')
49-
.pipe(plumber())
50-
.pipe(qunit());
46+
gulp.task('jshint', function () {
47+
return gulp.src(['knockout.mapping.js', 'spec/*.js'])
48+
.pipe(jshint())
49+
.pipe(jshint.reporter('jshint-stylish'));
5150
});
5251

53-
gulp.task('test-ci', function() {
54-
return gulp.src('spec/spec-runner-*.htm', {read:false})
55-
.pipe(qunit());
56-
});
57-
58-
gulp.task('test-jshint', function() {
59-
return gulp.src('spec/*.js')
60-
.pipe(jshint())
61-
.pipe(jshint.reporter('jshint-stylish'));
62-
});
52+
gulp.task('test', gulp.series('build', 'jshint', function() {
53+
return gulp.src(process.env.CI ? 'spec/spec-runner-*.htm' : 'spec/spec-runner.htm')
54+
.pipe(plumber({errorHandler: process.env.NODE_ENV === 'development'}))
55+
.pipe(qunit({timeout: 30}));
56+
}));
6357

64-
gulp.task('default', ['clear', 'build', 'test']);
58+
gulp.task('default', gulp.series('clear', 'test'));
6559

66-
gulp.task('watch', function() {
67-
gulp.watch('knockout.mapping.js', ['clear', 'build']);
68-
gulp.watch(['spec/spec-runner.htm', 'spec/*.js'], ['test']);
60+
gulp.task('watch', function () {
61+
gulp.watch(['knockout.mapping.js', 'spec/spec-runner.htm', 'spec/*.js'], gulp.series('clear', 'test'));
6962
});

package.json

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"dist",
88
"HISTORY.md"
99
],
10+
"engines": {
11+
"node": ">=6.9.5"
12+
},
1013
"keywords": [
1114
"knockout",
1215
"mapping",
@@ -19,22 +22,22 @@
1922
"knockout": ">=2.2.0"
2023
},
2124
"devDependencies": {
22-
"del": "^2.0.2",
23-
"gulp": "^3.8.11",
24-
"gulp-header": "^1.2.2",
25-
"gulp-if": "^2.0.0",
26-
"gulp-jshint": "^2.0.0",
27-
"gulp-plumber": "^1.0.1",
28-
"gulp-qunit": "^1.2.1",
29-
"gulp-rename": "^1.2.0",
30-
"gulp-replace": "^0.5.3",
31-
"gulp-sourcemaps": "^1.3.0",
32-
"gulp-uglify": "^1.1.0",
33-
"jshint": "^2.9.1",
34-
"jshint-stylish": "^2.0.1"
25+
"del": "^3.0.0",
26+
"gulp": "^4.0.0",
27+
"gulp-header": "^2.0.5",
28+
"gulp-if": "^2.0.2",
29+
"gulp-jshint": "^2.1.0",
30+
"gulp-plumber": "^1.2.0",
31+
"gulp-qunit": "^2.0.1",
32+
"gulp-rename": "^1.4.0",
33+
"gulp-replace": "^1.0.0",
34+
"gulp-sourcemaps": "^2.6.4",
35+
"gulp-uglify": "^3.0.1",
36+
"jshint": "^2.9.6",
37+
"jshint-stylish": "^2.2.1"
3538
},
3639
"scripts": {
37-
"test": "gulp test-ci"
40+
"test": "gulp test"
3841
},
3942
"repository": {
4043
"type": "git",

0 commit comments

Comments
 (0)