Skip to content

Commit 2b0d931

Browse files
author
Brad Berger
committed
Adds karma tests
1 parent 2376abf commit 2b0d931

16 files changed

+180
-48
lines changed

README.md

+24-9
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,36 @@ webdriver-manager start
122122
gulp
123123
```
124124

125-
Protractor is set up to run all the tests during development. To make it a bit
126-
faster development tests run using PhantomJS, while CI tests run with real
127-
browsers. JavaScript code is linted with `eslint`, too, so make sure that's
128-
not complaining about code styling or other issues.
125+
Protractor is set up to run all the tests during development. JavaScript code
126+
is linted with `eslint`, too, so make sure that's not complaining about code
127+
styling or other issues.
129128

130-
The CI test is `test-ci` while the standard tests run all the time while
131-
developing.
129+
Unit tests are thanks to Karma, so run those at the same time while developing.
130+
They'll detect code changes and run automatically in the background:
132131

133-
If you're having trouble with PhantomJS we can easily just switch to Chrome
134-
instead.
132+
```bash
133+
# In another terminal
134+
karma start
135+
```
136+
137+
## Contributing
138+
139+
Pull requests are most welcomed! The build process requires strict linting
140+
of code, so please follow the established ESLint style guide.
141+
142+
Also, the first round of the directive was just a proof-of-concept and test
143+
coverage is not complete, please do add tests for all new features and
144+
bug-fixes, too! Most submissions won't be merged without a test.
145+
146+
Also, if you could kindly add an extra test that's not related to your
147+
submission just to help us get to 100% coverage, that would be very much
148+
appreciated!
135149

136150
## To Do
137151

138152
- Unit tests (the basic setup is there, need to fill them out)
139-
- Verify the correct handling of timezones
153+
- Verify the correct handling of timezones (tests?)
140154
- Write documentation
141155
- Spread the work
142156
- Add to cdnjs, jsdelivr, etc.
157+
- Automate the website update process after successful CI build

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "material-calendar",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"homepage": "https://github.com/bradberger/material-calendar",
55
"keywords": "angular material design calendar ngCalendar mdCalendar calendarMd calendar-md md-calendar ng-calendar",
66
"authors": [

dist/angular-material-calendar.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

+4-10
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,15 @@ gulp.task("scss", function() {
6565
.pipe(connect.reload());
6666
});
6767

68-
gulp.task("test-ci", ["js:lint-ci"], function() {
68+
gulp.task("test", ["js:lint-ci"], function() {
6969
connect.server({ root: "website", port: 3000 });
7070
gulp
71-
.src(["./tests/*.spec.js"])
72-
.pipe(protractor({ configFile: p("protractor-ci.conf.js") }))
71+
.src(["./tests/e2e/**/*.spec.js"])
72+
.pipe(protractor({ configFile: p("protractor.conf.js") }))
7373
.on("error", function(e) { throw e; })
7474
.on("end", connect.serverClose);
7575
});
7676

77-
gulp.task("test", ["js:lint"], function() {
78-
gulp
79-
.src(["./tests/*.spec.js"])
80-
.pipe(protractor({ configFile: p("protractor.conf.js") }));
81-
});
82-
8377
gulp.task("build", function() {
8478
return runSequence(["scss"], "html", "js");
8579
});
@@ -89,7 +83,7 @@ gulp.task("connect", function() {
8983
});
9084

9185
gulp.task("watch", function() {
92-
gulp.watch(p("src/**/*"), ["test", "build"]);
86+
gulp.watch(p("src/**/*"), ["js:lint", "build"]);
9387
});
9488

9589
gulp.task("default", ["build", "connect", "watch"]);

karma.conf.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/* eslint-env node,jasmine */
2+
module.exports = function(config) {
3+
config.set({
4+
5+
// base path that will be used to resolve all patterns (eg. files, exclude)
6+
basePath: "",
7+
8+
// frameworks to use
9+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
10+
frameworks: ["jasmine"],
11+
12+
// list of files / patterns to load in the browser
13+
files: [
14+
"node_modules/angular/angular.min.js",
15+
"node_modules/angular-animate/angular-animate.min.js",
16+
"node_modules/angular-aria/angular-aria.min.js",
17+
"node_modules/angular-sanitize/angular-sanitize.min.js",
18+
"node_modules/angular-material/angular-material.min.js",
19+
"dist/angular-material-calendar.js",
20+
"node_modules/angular-mocks/angular-mocks.js",
21+
"test/unit/**/*.spec.js"
22+
],
23+
24+
// list of files to exclude
25+
exclude: [
26+
],
27+
28+
// preprocess matching files before serving them to the browser
29+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
30+
preprocessors: {
31+
},
32+
33+
// test results reporter to use
34+
// possible values: "dots", "progress"
35+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
36+
reporters: ["progress"],
37+
38+
// web server port
39+
port: 9876,
40+
41+
// enable / disable colors in the output (reporters and logs)
42+
colors: true,
43+
44+
// level of logging
45+
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
46+
logLevel: config.LOG_INFO,
47+
48+
// enable / disable watching file and executing tests whenever any file changes
49+
autoWatch: true,
50+
51+
// start these browsers
52+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
53+
browsers: ["Chrome"],
54+
55+
// Continuous Integration mode
56+
// if true, Karma captures browsers, runs the tests and exits
57+
singleRun: false
58+
59+
});
60+
};

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "angular-material-calendar",
3-
"version": "0.2.3",
3+
"version": "0.2.4",
44
"description": "A calendar directive for AngularJS and Angular Material Design",
55
"main": "gulpfile.js",
66
"scripts": {
7-
"test": "./node_modules/protractor/bin/webdriver-manager update && gulp test-ci"
7+
"postinstall": "./node_modules/protractor/bin/webdriver-manager update",
8+
"test": "karma start --single-run && gulp test"
89
},
910
"repository": {
1011
"type": "git",
@@ -30,8 +31,8 @@
3031
"gulp-sass": "^2.0.4",
3132
"gulp-size": "^2.0.0",
3233
"gulp-uglify": "^1.2.0",
34+
"karma": "^0.13.10",
3335
"node-sass": "^3.3.2",
34-
"phantomjs": "^1.9.18",
3536
"protractor": "^2.2.0",
3637
"replacestream": "^4.0.0",
3738
"run-sequence": "^1.1.2"

protractor-ci.conf.js

-13
This file was deleted.

0 commit comments

Comments
 (0)