Skip to content

Commit bec42c9

Browse files
committed
adding coverage report and code inspection to travis build
1 parent cabbfca commit bec42c9

File tree

9 files changed

+260
-24
lines changed

9 files changed

+260
-24
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
bower_components
33
node_modules
44
npm-debug.log
5+
target

Gruntfile.js

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
'use strict';
2+
3+
module.exports = function (grunt) {
4+
require('time-grunt')(grunt);
5+
require('load-grunt-tasks')(grunt);
6+
7+
grunt.config.init({
8+
BuildConfig: {
9+
testDirectory: 'test',
10+
exampleDirectory: 'example',
11+
targetDirectory: 'target'
12+
},
13+
14+
clean: {
15+
options: {
16+
force: true
17+
},
18+
dot: 'true',
19+
target: {
20+
src: [
21+
'<%=BuildConfig.targetDirectory%>/**'
22+
]
23+
}
24+
},
25+
26+
jsonlint: {
27+
full: {
28+
src: [
29+
'*.json'
30+
]
31+
}
32+
},
33+
34+
jshint: {
35+
full: {
36+
files: {
37+
src: [
38+
'angular-web-notification.js'
39+
]
40+
}
41+
},
42+
options: {
43+
jshintrc: true
44+
}
45+
},
46+
47+
jslint: {
48+
full: {
49+
src: [
50+
'angular-web-notification.js'
51+
],
52+
options: {
53+
edition: 'latest',
54+
failOnError: true
55+
},
56+
directives: {
57+
browser: true,
58+
vars: true,
59+
plusplus: true
60+
}
61+
}
62+
},
63+
64+
eslint: {
65+
full: {
66+
options: {
67+
config: '.eslintrc'
68+
},
69+
src: [
70+
'angular-web-notification.js'
71+
]
72+
}
73+
},
74+
75+
todos: {
76+
options: {
77+
priorities: {
78+
high: /(todo|TODO|fixme|FIXME)/
79+
}
80+
},
81+
full: {
82+
src: [
83+
'angular-web-notification.js',
84+
'<%=BuildConfig.testDirectory%>/**/*.js',
85+
'<%=BuildConfig.exampleDirectory%>/**/*.js'
86+
]
87+
}
88+
},
89+
90+
blanket: {
91+
full: {
92+
options: {
93+
'data-cover-only': 'angular-web-notification.js'
94+
},
95+
files: {
96+
'target/coverage/': ['./']
97+
}
98+
}
99+
},
100+
101+
karma: {
102+
full: {
103+
configFile: 'karma.conf.js',
104+
singleRun: true,
105+
browsers: ['PhantomJS']
106+
}
107+
},
108+
109+
coveralls: {
110+
options: {
111+
force: true
112+
},
113+
full: {
114+
src: '<%=BuildConfig.targetDirectory%>/coverage/report/*.info'
115+
}
116+
},
117+
118+
jsdoc2md: {
119+
api: {
120+
options: {
121+
index: true,
122+
'private': false
123+
},
124+
src: 'angular-web-notification.js',
125+
dest: 'docs/api.md'
126+
}
127+
}
128+
});
129+
130+
grunt.registerTask('full', 'Run all build steps.', [
131+
'jsonlint:full',
132+
'jshint:full',
133+
'jslint:full',
134+
'eslint:full',
135+
'todos:full',
136+
'jsdoc2md:api',
137+
'coverage'
138+
]);
139+
140+
grunt.registerTask('coverage', 'Run all module tests cases.', [
141+
'clean:target',
142+
'karma:full'
143+
]);
144+
145+
grunt.registerTask('continuesIntegration', 'Run all module tests cases.', [
146+
'jsonlint:full',
147+
'jshint:full',
148+
'jslint:full',
149+
'eslint:full',
150+
'todos:full',
151+
'coverage',
152+
'coveralls:full'
153+
]);
154+
};

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# angular-web-notification
22

3-
[![Bower Version](https://img.shields.io/bower/v/angular-web-notification.svg?style=flat)](https://github.com/sagiegurari/angular-web-notification/releases) [![Build Status](https://img.shields.io/travis/sagiegurari/angular-web-notification.svg?style=flat)](http://travis-ci.org/sagiegurari/angular-web-notification) [![bitHound Score](https://www.bithound.io/sagiegurari/angular-web-notification/badges/score.svg)](https://www.bithound.io/sagiegurari/angular-web-notification) [![Inline docs](http://inch-ci.org/github/sagiegurari/angular-web-notification.svg?branch=master)](http://inch-ci.org/github/sagiegurari/angular-web-notification)
3+
[![Bower Version](https://img.shields.io/bower/v/angular-web-notification.svg?style=flat)](https://github.com/sagiegurari/angular-web-notification/releases) [![Build Status](https://img.shields.io/travis/sagiegurari/angular-web-notification.svg?style=flat)](http://travis-ci.org/sagiegurari/angular-web-notification) [![Coverage Status](https://img.shields.io/coveralls/sagiegurari/angular-web-notification.svg?style=flat)](https://coveralls.io/r/sagiegurari/angular-web-notification) [![bitHound Score](https://www.bithound.io/sagiegurari/angular-web-notification/badges/score.svg)](https://www.bithound.io/sagiegurari/angular-web-notification) [![Inline docs](http://inch-ci.org/github/sagiegurari/angular-web-notification.svg?branch=master)](http://inch-ci.org/github/sagiegurari/angular-web-notification)
44

55
> Web Notifications AngularJS Service
66
@@ -75,7 +75,7 @@ See full docs at: [API Docs](docs/api.md)
7575

7676
| Date | Version | Description |
7777
| ----------- | ------- | ----------- |
78-
| 2015-03-11 | v0.0.12 | Maintenance |
78+
| 2015-03-12 | v0.0.13 | Maintenance |
7979
| 2015-02-16 | v0.0.7 | Automatic unit tests via karma |
8080
| 2015-02-05 | v0.0.5 | Doc changes |
8181
| 2014-12-30 | v0.0.4 | Doc changes |

angular-web-notification.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
} else if (argumentsArray.length === 1) {
9494
var value = argumentsArray.pop();
9595
if (typeof value === 'string') {
96-
title = value || '';
96+
title = value;
9797
options = {};
9898
} else {
9999
title = '';

bower.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-web-notification",
3-
"version": "0.0.12",
3+
"version": "0.0.13",
44
"authors": [
55
"Sagie Gur-Ari <[email protected]>"
66
],
@@ -18,7 +18,8 @@
1818
"bower_components",
1919
"test",
2020
"tests",
21-
"example"
21+
"example",
22+
"target"
2223
],
2324
"dependencies": {
2425
"HTML5-Desktop-Notifications": "https://github.com/ttsvetko/HTML5-Desktop-Notifications.git",

karma.conf.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
module.exports = function (config) {
32
'use strict';
43

@@ -17,6 +16,19 @@ module.exports = function (config) {
1716
logLevel: config.LOG_INFO,
1817
autoWatch: false,
1918
browsers: ['PhantomJS'],
20-
singleRun: false
19+
singleRun: false,
20+
reporters: ['progress', 'coverage'],
21+
preprocessors: {
22+
'angular-web-notification.js': ['coverage']
23+
},
24+
coverageReporter: {
25+
dir: 'target/coverage/report',
26+
reporters: [
27+
{
28+
type: 'lcov',
29+
subdir: '.'
30+
}
31+
]
32+
}
2133
});
2234
};

package.json

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,29 @@
2222
"notification"
2323
],
2424
"devDependencies": {
25-
"jsdoc-to-markdown": "*",
25+
"grunt": "*",
26+
"grunt-cli": "*",
27+
"grunt-contrib-clean": "*",
28+
"grunt-contrib-jshint": "*",
29+
"grunt-coveralls": "*",
30+
"grunt-eslint": "*",
31+
"grunt-jsdoc-to-markdown": "*",
32+
"grunt-jslint": "*",
33+
"grunt-jsonlint": "*",
34+
"grunt-karma": "*",
35+
"grunt-todos": "*",
2636
"karma": "*",
2737
"karma-cli": "*",
38+
"karma-coverage": "*",
2839
"karma-mocha": "*",
2940
"karma-phantomjs-launcher": "*",
30-
"karma-sinon-chai": "*"
41+
"karma-sinon-chai": "*",
42+
"load-grunt-tasks": "*",
43+
"time-grunt": "*"
3144
},
3245
"scripts": {
33-
"test": "karma start karma.conf.js --single-run",
34-
"docs": "jsdoc2md angular-web-notification.js > docs/api.md"
46+
"test": "grunt continuesIntegration",
47+
"docs": "grunt jsdoc2md:api"
3548
},
3649
"license": "Apache 2",
3750
"bugs": {

test/helpers/notify-mock.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,51 @@ window.notify = (function () {
2424
lib.createNotification = function (title, options) {
2525
lib.validateNotification(title, options);
2626

27-
return function mockClose() {
28-
return undefined;
27+
return {
28+
close: function mockClose() {
29+
return undefined;
30+
}
2931
};
3032
};
3133

32-
lib.setAllowed = function (validateNotification) {
34+
lib.setValidationNotification = function (validateNotification) {
3335
lib.validateNotification = validateNotification || function () {
3436
return undefined;
3537
};
38+
};
39+
40+
lib.setAllowed = function (validateNotification) {
41+
lib.setValidationNotification(validateNotification);
3642

3743
lib.isSupported = true;
3844
permission = 'granted';
3945
};
4046

4147
lib.setSupportedOnly = function () {
48+
lib.setValidationNotification(null);
4249
lib.isSupported = true;
4350
permission = 'not-granted';
4451
};
4552

4653
lib.setNotSupported = function () {
54+
lib.setValidationNotification(null);
4755
lib.isSupported = false;
4856
permission = 'not-granted';
4957
};
5058

59+
lib.setFirstTimePermissions = function (validateNotification) {
60+
lib.orgRequestPermission = lib.requestPermission;
61+
lib.setValidationNotification(validateNotification);
62+
63+
lib.requestPermission = function (callback) {
64+
permission = 'granted';
65+
66+
lib.orgRequestPermission(callback);
67+
lib.requestPermission = lib.orgRequestPermission;
68+
};
69+
70+
lib.setSupportedOnly();
71+
};
72+
5173
return lib;
5274
}());

0 commit comments

Comments
 (0)