jasmine-growl-reporter
Advanced tools
Comparing version 0.0.2 to 0.2.0
@@ -12,23 +12,31 @@ | ||
reportRunnerStarting: function() { | ||
jasmineStarted: function() { | ||
this.startedAt = new Date(); | ||
this.passedSpecs = 0; | ||
this.totalSpecs = 0; | ||
this.counts = { | ||
failed: 0, | ||
pending: 0, | ||
total: 0 | ||
}; | ||
}, | ||
reportSpecStarting: function() { | ||
this.totalSpecs++; | ||
specStarted: function() { | ||
this.counts.total++; | ||
}, | ||
reportSpecResults: function(spec) { | ||
if (spec.results().passed()) { | ||
this.passedSpecs++; | ||
specDone: function(spec) { | ||
switch (spec.status) { | ||
case 'pending': | ||
this.counts.pending++; | ||
break; | ||
case 'failed': | ||
this.counts.failed++; | ||
break; | ||
} | ||
}, | ||
reportRunnerResults: function() { | ||
jasmineDone: function() { | ||
growl(growlMessage(this.passedSpecs, this.totalSpecs), { | ||
growl(growlMessage(this.counts), { | ||
name: growlName, | ||
title: growlTitle(this.passedSpecs, this.totalSpecs, this.startedAt) | ||
title: growlTitle(this.counts, this.startedAt) | ||
}); | ||
@@ -40,5 +48,5 @@ } | ||
var growlTitle = function(passedSpecs, totalSpecs, startedAt) { | ||
var growlTitle = function(counts, startedAt) { | ||
var title = passedSpecs < totalSpecs ? 'FAILED' : 'PASSED'; | ||
var title = counts.failed ? 'FAILED' : 'PASSED'; | ||
title += ' in ' + ((new Date().getTime() - startedAt.getTime()) / 1000) + 's'; | ||
@@ -49,12 +57,13 @@ | ||
var growlMessage = function(passedSpecs, totalSpecs) { | ||
var growlMessage = function(counts) { | ||
var description = passedSpecs + ' tests passed'; | ||
var description = counts.total + ' tests'; | ||
var failedSpecs = totalSpecs - passedSpecs; | ||
if (failedSpecs) { | ||
description += ', ' + failedSpecs + ' tests failed'; | ||
if (counts.total) { | ||
description += ', ' + counts.failed + ' failed'; | ||
} | ||
description += ', ' + totalSpecs + ' total'; | ||
if (counts.pending) { | ||
description += ', ' + counts.pending + ' pending'; | ||
} | ||
@@ -61,0 +70,0 @@ return description; |
@@ -1,2 +0,2 @@ | ||
Copyright (c) 2013 Simon Oulevay (Alpha Hydrae) | ||
Copyright (c) 2013-2014 Simon Oulevay (Alpha Hydrae) | ||
@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining |
{ | ||
"name": "jasmine-growl-reporter", | ||
"version": "0.0.2", | ||
"version": "0.2.0", | ||
"main": "./index.js", | ||
"scripts": { | ||
"test": "grunt" | ||
"test": "jasmine-node spec" | ||
}, | ||
@@ -12,9 +12,9 @@ "dependencies": { | ||
"devDependencies": { | ||
"grunt": "~0.4.1", | ||
"grunt-bump": "~0.0.11", | ||
"grunt-contrib-jshint": "~0.6.0", | ||
"grunt": "~0.4.2", | ||
"grunt-bump": "~0.0.13", | ||
"grunt-contrib-jshint": "~0.8.0", | ||
"grunt-jasmine-node": "~0.1.0", | ||
"grunt-contrib-watch": "~0.5.1", | ||
"jasmine-node": "~1.10.2", | ||
"underscore": "~1.5.1" | ||
"grunt-contrib-watch": "~0.5.3", | ||
"jasmine-node": "~1.13.1", | ||
"underscore": "~1.6.0" | ||
}, | ||
@@ -21,0 +21,0 @@ "homepage": "https://github.com/AlphaHydrae/jasmine-growl-reporter", |
@@ -9,2 +9,6 @@ # Jasmine Growl Reporter | ||
![jasmine-growl-reporter](https://raw.github.com/AlphaHydrae/jasmine-growl-reporter/master/res/screenshot.png) | ||
See [node-growl](https://github.com/visionmedia/node-growl) for platform-specific support. | ||
## Meta | ||
@@ -11,0 +15,0 @@ |
@@ -11,14 +11,14 @@ | ||
var fakeSpecResults = function(passed) { | ||
var fakeSpecResult = function(passed) { | ||
return { | ||
results: function() { | ||
return { | ||
passed: function() { | ||
return passed; | ||
} | ||
} | ||
} | ||
status: passed ? 'passed' : 'failed' | ||
}; | ||
}; | ||
var pendingSpecResult = function() { | ||
return { | ||
status: 'pending' | ||
}; | ||
}; | ||
var title = 'Jasmine', | ||
@@ -34,5 +34,5 @@ passedRegexp = /^PASSED in [\d\.]+s$/, | ||
it("should report 0 results", function() { | ||
reporter.reportRunnerStarting(); | ||
reporter.reportRunnerResults(); | ||
expect(growl).toHaveNotified('0 tests passed, 0 total', { | ||
reporter.jasmineStarted(); | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('0 tests', { | ||
name: title, | ||
@@ -44,9 +44,9 @@ title: passedRegexp | ||
it("should report 2 successful results", function() { | ||
reporter.reportRunnerStarting(); | ||
reporter.jasmineStarted(); | ||
_.times(2, function() { | ||
reporter.reportSpecStarting(); | ||
reporter.reportSpecResults(fakeSpecResults(true)); | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(true)); | ||
}); | ||
reporter.reportRunnerResults(); | ||
expect(growl).toHaveNotified('2 tests passed, 2 total', { | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('2 tests, 0 failed', { | ||
name: title, | ||
@@ -58,9 +58,9 @@ title: passedRegexp | ||
it("should report 3 failed results", function() { | ||
reporter.reportRunnerStarting(); | ||
reporter.jasmineStarted(); | ||
_.times(3, function() { | ||
reporter.reportSpecStarting(); | ||
reporter.reportSpecResults(fakeSpecResults(false)); | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(false)); | ||
}); | ||
reporter.reportRunnerResults(); | ||
expect(growl).toHaveNotified('0 tests passed, 3 tests failed, 3 total', { | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('3 tests, 3 failed', { | ||
name: title, | ||
@@ -72,13 +72,13 @@ title: failedRegexp | ||
it("should report 2 passed and 4 failed results", function() { | ||
reporter.reportRunnerStarting(); | ||
reporter.jasmineStarted(); | ||
_.times(2, function() { | ||
reporter.reportSpecStarting(); | ||
reporter.reportSpecResults(fakeSpecResults(true)); | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(true)); | ||
}); | ||
_.times(4, function() { | ||
reporter.reportSpecStarting(); | ||
reporter.reportSpecResults(fakeSpecResults(false)); | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(false)); | ||
}); | ||
reporter.reportRunnerResults(); | ||
expect(growl).toHaveNotified('2 tests passed, 4 tests failed, 6 total', { | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('6 tests, 4 failed', { | ||
name: title, | ||
@@ -88,2 +88,70 @@ title: failedRegexp | ||
}); | ||
it("should report 3 pending results", function() { | ||
reporter.jasmineStarted(); | ||
_.times(3, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(pendingSpecResult()); | ||
}); | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('3 tests, 0 failed, 3 pending', { | ||
name: title, | ||
title: passedRegexp | ||
}); | ||
}); | ||
it("should report 1 passed and 2 pending results", function() { | ||
reporter.jasmineStarted(); | ||
_.times(1, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(true)); | ||
}); | ||
_.times(2, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(pendingSpecResult()); | ||
}); | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('3 tests, 0 failed, 2 pending', { | ||
name: title, | ||
title: passedRegexp | ||
}); | ||
}); | ||
it("should report 4 pending and 5 failed results", function() { | ||
reporter.jasmineStarted(); | ||
_.times(4, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(pendingSpecResult()); | ||
}); | ||
_.times(5, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(false)); | ||
}); | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('9 tests, 5 failed, 4 pending', { | ||
name: title, | ||
title: failedRegexp | ||
}); | ||
}); | ||
it("should report 2 passed, 3 pending and 4 failed results", function() { | ||
reporter.jasmineStarted(); | ||
_.times(2, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(true)); | ||
}); | ||
_.times(3, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(pendingSpecResult()); | ||
}); | ||
_.times(4, function() { | ||
reporter.specStarted(); | ||
reporter.specDone(fakeSpecResult(false)); | ||
}); | ||
reporter.jasmineDone(); | ||
expect(growl).toHaveNotified('9 tests, 4 failed, 3 pending', { | ||
name: title, | ||
title: failedRegexp | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18477
12
255
17