Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'feature/non-chrome-support' into develop

  • Loading branch information...
commit 290cb36ce7f5e3fca8eb84f9fc2912dcef4a12ba 2 parents 5b4646f + 4aec8c7
@demiazz authored
View
24 README.md
@@ -48,3 +48,27 @@ This is simple example of usage. :
When specs are running, will be used TrivialReporter (default for Jasmine), and
WebkitReporter.
+
+## Options
+
+WebKit Reporter have custom options:
+ * title - name of testing application;
+ * replaceId - custom replaceId for notifications (see Notifications API Draft);
+ * timeout - of timeout is greater such 0, then notifications will be autoclosed after timeout;
+ * passedIcon - icon for notifications about passed running;
+ * failedIcon - icon for notifications about failed running;
+ * runningIcon - icon for notifications about running.
+
+### Notes about icons
+
+Icons will be a URL or empty string for not showning icons.
+
+If you want enable icon, then recommend set as URL to icon.
+
+## Browsers without webkitNotifications
+
+If browser have not window.webkitNotifications, when reporter creating methods
+`reportRunnerStarting` and `reportRunnerResults` replaced by empty methods.
+
+This is make possible using library in non supported browsers without exceptions,
+and any actions for disabling of reporter.
View
23 jasmine-wkreporter.js
@@ -91,16 +91,21 @@
function WebkitReporter(options) {
if (options == null) options = {};
- if (options) {
- if (options.title) this.title = options.title;
- if (options.replaceId) this.replaceId = options.replaceId;
- if (options.timeout) this.timeout = options.timeout;
- if (options.passedIcon) this.passedIcon = options.passedIcon;
- if (options.failedIcon) this.failedIcon = options.failedIcon;
- if (options.runningIcon) this.runningIcon = options.runningIcon;
+ if (jasmine.getGlobal().webkitNotifications) {
+ if (options) {
+ if (options.title) this.title = options.title;
+ if (options.replaceId) this.replaceId = options.replaceId;
+ if (options.timeout) this.timeout = options.timeout;
+ if (options.passedIcon) this.passedIcon = options.passedIcon;
+ if (options.failedIcon) this.failedIcon = options.failedIcon;
+ if (options.runningIcon) this.runningIcon = options.runningIcon;
+ }
+ this.startedAt = null;
+ this.finishedAt = null;
+ } else {
+ this.reportRunnerStarting = function() {};
+ this.reportRunnerResults = function() {};
}
- this.startedAt = null;
- this.finishedAt = null;
return;
}
View
2  jasmine-wkreporter.min.js
@@ -6,4 +6,4 @@
@author Alexey Plutalov <demiazz.py@gmail.com>
@since Jasmine Webkit Reporter 0.1
-*/((function(){var a=Object.prototype.hasOwnProperty,b=function(b,c){function e(){this.constructor=b}for(var d in c)a.call(c,d)&&(b[d]=c[d]);return e.prototype=c.prototype,b.prototype=new e,b.__super__=c.prototype,b};jasmine.WebkitReporter=function(a){function c(a){a==null&&(a={}),a&&(a.title&&(this.title=a.title),a.replaceId&&(this.replaceId=a.replaceId),a.timeout&&(this.timeout=a.timeout),a.passedIcon&&(this.passedIcon=a.passedIcon),a.failedIcon&&(this.failedIcon=a.failedIcon),a.runningIcon&&(this.runningIcon=a.runningIcon)),this.startedAt=null,this.finishedAt=null;return}return b(c,a),c.prototype.title="Jasmine",c.prototype.replaceId="jasmine",c.prototype.timeout=0,c.prototype.passedIcon="",c.prototype.failedIcon="",c.prototype.runningIcon="",c.prototype.reportRunnerStarting=function(a){var b;jasmine.getGlobal().webkitNotifications.checkPermission()===0?(this.startedAt=new Date,this.finishedAt=null,this.title&&this.title.length>0?b=""+this.title+": RUNNING":b="RUNNING",this.showReport(this.runningIcon,b,"Running specs. Please wait...")):jasmine.getGlobal().webkitNotifications.requestPermission()},c.prototype.reportRunnerResults=function(a){var b,c,d,e,f;this.finishedAt=new Date,jasmine.getGlobal().webkitNotifications.checkPermission()===0?(b="",f="",c="",e=(this.finishedAt.getTime()-this.startedAt.getTime())/1e3,this.title&&this.title.length>0&&(f=this.title+": "),d=a.results(),d.failedCount>0?(b=this.failedIcon,f+="FAILED"):(b=this.passedIcon,f+="PASSED"),c+=""+d.totalCount+" spec"+(d.totalCount===1?"":"s"),c+=", "+d.failedCount+" failure"+(d.failedCount===1?"":"s"),c+=" in "+e+"s",this.showReport(b,f,c)):jasmine.getGlobal().webkitNotifications.requestPermission()},c.prototype.showReport=function(a,b,c){var d;d=jasmine.getGlobal().webkitNotifications.createNotification(a,b,c),d.replaceId=this.replaceId,d.show(),this.timeout>0&&setTimeout(function(){d.cancel()},this.timeout)},c}(jasmine.Reporter)})).call(this);
+*/((function(){var a=Object.prototype.hasOwnProperty,b=function(b,c){function e(){this.constructor=b}for(var d in c)a.call(c,d)&&(b[d]=c[d]);return e.prototype=c.prototype,b.prototype=new e,b.__super__=c.prototype,b};jasmine.WebkitReporter=function(a){function c(a){a==null&&(a={}),jasmine.getGlobal().webkitNotifications?(a&&(a.title&&(this.title=a.title),a.replaceId&&(this.replaceId=a.replaceId),a.timeout&&(this.timeout=a.timeout),a.passedIcon&&(this.passedIcon=a.passedIcon),a.failedIcon&&(this.failedIcon=a.failedIcon),a.runningIcon&&(this.runningIcon=a.runningIcon)),this.startedAt=null,this.finishedAt=null):(this.reportRunnerStarting=function(){},this.reportRunnerResults=function(){});return}return b(c,a),c.prototype.title="Jasmine",c.prototype.replaceId="jasmine",c.prototype.timeout=0,c.prototype.passedIcon="",c.prototype.failedIcon="",c.prototype.runningIcon="",c.prototype.reportRunnerStarting=function(a){var b;jasmine.getGlobal().webkitNotifications.checkPermission()===0?(this.startedAt=new Date,this.finishedAt=null,this.title&&this.title.length>0?b=""+this.title+": RUNNING":b="RUNNING",this.showReport(this.runningIcon,b,"Running specs. Please wait...")):jasmine.getGlobal().webkitNotifications.requestPermission()},c.prototype.reportRunnerResults=function(a){var b,c,d,e,f;this.finishedAt=new Date,jasmine.getGlobal().webkitNotifications.checkPermission()===0?(b="",f="",c="",e=(this.finishedAt.getTime()-this.startedAt.getTime())/1e3,this.title&&this.title.length>0&&(f=this.title+": "),d=a.results(),d.failedCount>0?(b=this.failedIcon,f+="FAILED"):(b=this.passedIcon,f+="PASSED"),c+=""+d.totalCount+" spec"+(d.totalCount===1?"":"s"),c+=", "+d.failedCount+" failure"+(d.failedCount===1?"":"s"),c+=" in "+e+"s",this.showReport(b,f,c)):jasmine.getGlobal().webkitNotifications.requestPermission()},c.prototype.showReport=function(a,b,c){var d;d=jasmine.getGlobal().webkitNotifications.createNotification(a,b,c),d.replaceId=this.replaceId,d.show(),this.timeout>0&&setTimeout(function(){d.cancel()},this.timeout)},c}(jasmine.Reporter)})).call(this);
View
23 lib/reporter.coffee
@@ -75,15 +75,20 @@ class jasmine.WebkitReporter extends jasmine.Reporter
@param {Object|null} options - options for reporter
###
constructor: (options = {}) ->
- if options
- @title = options.title if options.title
- @replaceId = options.replaceId if options.replaceId
- @timeout = options.timeout if options.timeout
- @passedIcon = options.passedIcon if options.passedIcon
- @failedIcon = options.failedIcon if options.failedIcon
- @runningIcon = options.runningIcon if options.runningIcon
- @startedAt = null
- @finishedAt = null
+ if jasmine.getGlobal().webkitNotifications
+ if options
+ @title = options.title if options.title
+ @replaceId = options.replaceId if options.replaceId
+ @timeout = options.timeout if options.timeout
+ @passedIcon = options.passedIcon if options.passedIcon
+ @failedIcon = options.failedIcon if options.failedIcon
+ @runningIcon = options.runningIcon if options.runningIcon
+ @startedAt = null
+ @finishedAt = null
+ else
+ # safe stubing functions for reporting by empty methods
+ @reportRunnerStarting = () ->
+ @reportRunnerResults = () ->
return
###
Please sign in to comment.
Something went wrong with that request. Please try again.