Skip to content

Commit

Permalink
Merge pull request #14 from stocksr/patch-1
Browse files Browse the repository at this point in the history
make the tick and cross symbols optional
  • Loading branch information
bcaudan committed Aug 12, 2014
2 parents 3fa34f5 + 4136ef3 commit 004dcf1
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 6 deletions.
86 changes: 86 additions & 0 deletions spec/jasmine-spec-reporter.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,92 @@ describe 'spec reporter', ->
).outputs)
.contains /✗ failed spec \({time}\)/

describe 'with prefixes set to empty strings', ->
beforeEach ->
@reporter = new jasmine.SpecReporter({displaySkippedSpec: true, prefixes: {success: '', failure: '', skipped: ''}})

describe 'when spec', ->
it 'should report success', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@it 'successful spec', ->
@passed()
).outputs)
.not.contains //


it 'should report failure', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@it 'failed spec', ->
@failed()
).outputs)
.not.contains //

it 'should report skipped', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@xit 'skipped spec', ->
).outputs)
.not.contains /-/

describe 'with prefixes set to valid strings', ->
beforeEach ->
@reporter = new jasmine.SpecReporter({displaySkippedSpec: true, prefixes: {success: 'Pass ', failure: 'Fail ', skipped: 'Skip '}})

describe 'when spec', ->
it 'should report success', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@it 'successful spec', ->
@passed()
).outputs)
.not.contains //


it 'should report failure', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@it 'failed spec', ->
@failed()
).outputs)
.not.contains //

it 'should report skipped', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@xit 'skipped spec', ->
).outputs)
.not.contains /-/

describe 'with prefixes not set', ->
beforeEach ->
@reporter = new jasmine.SpecReporter({displaySkippedSpec: true, prefixes: {} })

describe 'when spec', ->
it 'should report success', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@it 'successful spec', ->
@passed()
).outputs)
.contains //


it 'should report failure', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@it 'failed spec', ->
@failed()
).outputs)
.contains //

it 'should report skipped', ->
expect(new Test(@reporter,->
@describe 'suite', ->
@xit 'skipped spec', ->
).outputs)
.contains /-/

describe 'with jasmine callback hack', ->
beforeEach ->
Expand Down
17 changes: 11 additions & 6 deletions src/jasmine-spec-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ var SpecDisplay = function (options) {
this.displaySkippedSpec = options.displaySkippedSpec || false;
this.displaySpecDuration = options.displaySpecDuration || false;
this.displayWithoutColors = options.colors === false;
this.prefixes = {
success: options.prefixes && options.prefixes.success !== undefined ? options.prefixes.success : '✓ ',
failure: options.prefixes && options.prefixes.failure !== undefined ? options.prefixes.failure : '✗ ',
skipped: options.prefixes && options.prefixes.skipped !== undefined ? options.prefixes.skipped : '- '
};

colors.setTheme({
success: options.colors && options.colors.success ? options.colors.success : 'green',
Expand Down Expand Up @@ -116,28 +121,28 @@ SpecDisplay.prototype = {
successful: function (spec) {
if (this.displaySuccessfulSpec) {
this.ensureSuiteDisplayed(spec.suite);
var result = '✓ ' + spec.results().description;
var result = spec.results().description;
var duration = this.displaySpecDuration ? ' (' + spec.duration + ')' : '';
this.log(result.success + duration)
this.log(this.prefixes.success + result.success + duration)
}
},

failed: function (spec) {
this.failedSpecs.push(spec);
if (this.displayFailedSpec) {
this.ensureSuiteDisplayed(spec.suite);
var result = '✗ ' + spec.results().description;
var result = spec.results().description;
var duration = this.displaySpecDuration ? ' (' + spec.duration + ')' : '';
this.log(result.failure + duration);
this.log(this.prefixes.failure + result.failure + duration);
this.displayErrorMessages(spec);
}
},

skipped: function (spec) {
if (this.displaySkippedSpec) {
this.ensureSuiteDisplayed(spec.suite);
var result = '- ' + spec.results().description;
this.log(result.skipped)
var result = spec.results().description;
this.log(this.prefixes.skipped + result.skipped)
}
},

Expand Down

0 comments on commit 004dcf1

Please sign in to comment.