Skip to content

Commit

Permalink
Merge branch 'release/0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
demiazz committed Jan 28, 2012
2 parents a15c800 + 290cb36 commit 46ecddb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 19 deletions.
24 changes: 24 additions & 0 deletions README.md
Expand Up @@ -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.
23 changes: 14 additions & 9 deletions jasmine-wkreporter.js
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion jasmine-wkreporter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 14 additions & 9 deletions lib/reporter.coffee
Expand Up @@ -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

###
Expand Down

0 comments on commit 46ecddb

Please sign in to comment.