@@ -45,12 +45,20 @@ describe('Jasmine', function() {
45
45
expect ( this . testJasmine . coreVersion ( ) ) . toEqual ( 'a version' ) ;
46
46
} ) ;
47
47
48
+ it ( 'registers a console reporter upon construction' , function ( ) {
49
+ spyOn ( Jasmine , 'ConsoleReporter' ) . and . returnValue ( { someProperty : 'some value' } ) ;
50
+
51
+ var testJasmine = new Jasmine ( { jasmineCore : this . fakeJasmineCore } ) ;
52
+
53
+ expect ( testJasmine . env . addReporter ) . toHaveBeenCalledWith ( { someProperty : 'some value' } ) ;
54
+ } ) ;
55
+
48
56
describe ( '#configureDefaultReporter' , function ( ) {
49
57
beforeEach ( function ( ) {
50
- spyOn ( Jasmine , 'ConsoleReporter' ) . and . returnValue ( { someProperty : 'some value' } ) ;
58
+ spyOn ( this . testJasmine . reporter , 'setOptions' ) ;
51
59
} ) ;
52
60
53
- it ( 'creates a reporter with the passed in options ' , function ( ) {
61
+ it ( 'sets the options on the console reporter ' , function ( ) {
54
62
var reporterOptions = {
55
63
print : 'printer' ,
56
64
showColors : true ,
@@ -65,8 +73,7 @@ describe('Jasmine', function() {
65
73
66
74
this . testJasmine . configureDefaultReporter ( reporterOptions ) ;
67
75
68
- expect ( Jasmine . ConsoleReporter ) . toHaveBeenCalledWith ( expectedReporterOptions ) ;
69
- expect ( this . testJasmine . env . provideFallbackReporter ) . toHaveBeenCalledWith ( { someProperty : 'some value' } ) ;
76
+ expect ( this . testJasmine . reporter . setOptions ) . toHaveBeenCalledWith ( expectedReporterOptions ) ;
70
77
} ) ;
71
78
72
79
it ( 'creates a reporter with a default option if an option is not specified' , function ( ) {
@@ -81,28 +88,7 @@ describe('Jasmine', function() {
81
88
jasmineCorePath : 'fake/jasmine/path/jasmine.js'
82
89
} ;
83
90
84
- expect ( Jasmine . ConsoleReporter ) . toHaveBeenCalledWith ( expectedReporterOptions ) ;
85
- expect ( this . testJasmine . env . provideFallbackReporter ) . toHaveBeenCalledWith ( { someProperty : 'some value' } ) ;
86
- } ) ;
87
-
88
- describe ( 'sets the defaultReportedAdded flag' , function ( ) {
89
- it ( 'to true if the default reporter is used' , function ( ) {
90
- var reporterOptions = { } ;
91
-
92
- this . testJasmine . configureDefaultReporter ( reporterOptions ) ;
93
-
94
- expect ( this . testJasmine . defaultReporterAdded ) . toBe ( true ) ;
95
- } ) ;
96
-
97
- it ( 'to false if the default reporter is not used' , function ( ) {
98
- var reporterOptions = { } ;
99
- var dummyReporter = { } ;
100
-
101
- this . testJasmine . addReporter ( dummyReporter ) ;
102
- this . testJasmine . configureDefaultReporter ( reporterOptions ) ;
103
-
104
- expect ( this . testJasmine . defaultReporterAdded ) . toBe ( false ) ;
105
- } ) ;
91
+ expect ( this . testJasmine . reporter . setOptions ) . toHaveBeenCalledWith ( expectedReporterOptions ) ;
106
92
} ) ;
107
93
108
94
describe ( 'passing in an onComplete function' , function ( ) {
@@ -263,10 +249,10 @@ describe('Jasmine', function() {
263
249
describe ( '#onComplete' , function ( ) {
264
250
it ( 'stores an onComplete function' , function ( ) {
265
251
var fakeOnCompleteCallback = function ( ) { } ;
266
- spyOn ( this . testJasmine . exitCodeReporter , 'onComplete' ) ;
252
+ spyOn ( this . testJasmine . completionReporter , 'onComplete' ) ;
267
253
268
254
this . testJasmine . onComplete ( fakeOnCompleteCallback ) ;
269
- expect ( this . testJasmine . exitCodeReporter . onComplete ) . toHaveBeenCalledWith ( fakeOnCompleteCallback ) ;
255
+ expect ( this . testJasmine . completionReporter . onComplete ) . toHaveBeenCalledWith ( fakeOnCompleteCallback ) ;
270
256
} ) ;
271
257
} ) ;
272
258
@@ -302,20 +288,6 @@ describe('Jasmine', function() {
302
288
expect ( this . testJasmine . env . execute ) . toHaveBeenCalled ( ) ;
303
289
} ) ;
304
290
305
- it ( 'adds a default reporter as a fallback reporter' , function ( ) {
306
- this . testJasmine . addReporter ( new Jasmine . ConsoleReporter ( { } ) ) ;
307
-
308
- //spyOn(this.testJasmine, 'configureDefaultReporter');
309
- spyOn ( this . testJasmine , 'loadSpecs' ) ;
310
-
311
- this . testJasmine . execute ( ) ;
312
-
313
- expect ( this . testJasmine . env . provideFallbackReporter ) . toHaveBeenCalled ( ) ;
314
- expect ( this . testJasmine . env . addReporter ) . toHaveBeenCalled ( ) ;
315
- expect ( this . testJasmine . loadSpecs ) . toHaveBeenCalled ( ) ;
316
- expect ( this . testJasmine . env . execute ) . toHaveBeenCalled ( ) ;
317
- } ) ;
318
-
319
291
it ( 'loads helper files before checking if any reporters were added' , function ( ) {
320
292
var loadHelpers = spyOn ( this . testJasmine , 'loadHelpers' ) ;
321
293
spyOn ( this . testJasmine , 'configureDefaultReporter' ) . and . callFake ( function ( ) {
@@ -351,56 +323,30 @@ describe('Jasmine', function() {
351
323
} ) ;
352
324
353
325
it ( 'adds an exit code reporter' , function ( ) {
354
- var exitCodeReporterSpy = jasmine . createSpyObj ( 'reporter' , [ 'onComplete' ] ) ;
355
- this . testJasmine . exitCodeReporter = exitCodeReporterSpy ;
326
+ var completionReporterSpy = jasmine . createSpyObj ( 'reporter' , [ 'onComplete' ] ) ;
327
+ this . testJasmine . completionReporter = completionReporterSpy ;
356
328
spyOn ( this . testJasmine , 'addReporter' ) ;
357
329
358
330
this . testJasmine . execute ( ) ;
359
331
360
- expect ( this . testJasmine . addReporter ) . toHaveBeenCalledWith ( exitCodeReporterSpy ) ;
332
+ expect ( this . testJasmine . addReporter ) . toHaveBeenCalledWith ( completionReporterSpy ) ;
361
333
} ) ;
362
334
363
335
describe ( 'default completion behavior' , function ( ) {
364
- describe ( 'when the defaultReporterAdded flag is truthy' , function ( ) {
365
- beforeEach ( function ( ) {
366
- this . testJasmine . configureDefaultReporter ( { } ) ;
367
- } ) ;
368
- it ( 'exits successfully when the whole suite is green' , function ( ) {
369
- var exitSpy = jasmine . createSpy ( 'exit' ) ;
370
- this . testJasmine . exit = exitSpy ;
336
+ it ( 'exits successfully when the whole suite is green' , function ( ) {
337
+ var exitSpy = jasmine . createSpy ( 'exit' ) ;
338
+ this . testJasmine . exit = exitSpy ;
371
339
372
- var exitCodeReporterSpy = jasmine . createSpyObj ( 'reporter' , [ 'onComplete' ] ) ;
373
- this . testJasmine . exitCodeReporter = exitCodeReporterSpy ;
374
-
375
- this . testJasmine . execute ( ) ;
376
- exitCodeReporterSpy . onComplete . calls . mostRecent ( ) . args [ 0 ] ( true ) ;
377
- expect ( exitSpy ) . toHaveBeenCalledWith ( 0 , process . platform , process . version , process . exit , require ( 'exit' ) ) ;
378
- } ) ;
379
-
380
- it ( 'exits with a failure when anything in the suite is not green' , function ( ) {
381
- var exitSpy = jasmine . createSpy ( 'exit' ) ;
382
- this . testJasmine . exit = exitSpy ;
383
-
384
- var exitCodeReporterSpy = jasmine . createSpyObj ( 'reporter' , [ 'onComplete' ] ) ;
385
- this . testJasmine . exitCodeReporter = exitCodeReporterSpy ;
386
-
387
- this . testJasmine . execute ( ) ;
388
- exitCodeReporterSpy . onComplete . calls . mostRecent ( ) . args [ 0 ] ( false ) ;
389
- expect ( exitSpy ) . toHaveBeenCalledWith ( 1 , process . platform , process . version , process . exit , require ( 'exit' ) ) ;
390
- } ) ;
340
+ this . testJasmine . exitCodeCompletion ( true ) ;
341
+ expect ( exitSpy ) . toHaveBeenCalledWith ( 0 , process . platform , process . version , process . exit , require ( 'exit' ) ) ;
391
342
} ) ;
392
343
393
- describe ( 'when the defaultReporterAdded flag is falsy' , function ( ) {
394
- it ( 'does not exit the process' , function ( ) {
395
- var exitSpy = jasmine . createSpy ( 'exit' ) ;
396
- this . testJasmine . exit = exitSpy ;
344
+ it ( 'exits with a failure when anything in the suite is not green' , function ( ) {
345
+ var exitSpy = jasmine . createSpy ( 'exit' ) ;
346
+ this . testJasmine . exit = exitSpy ;
397
347
398
- var exitCodeReporterSpy = jasmine . createSpyObj ( 'reporter' , [ 'onComplete' ] ) ;
399
- this . testJasmine . exitCodeReporter = exitCodeReporterSpy ;
400
-
401
- this . testJasmine . execute ( ) ;
402
- expect ( exitSpy ) . not . toHaveBeenCalled ( ) ;
403
- } ) ;
348
+ this . testJasmine . exitCodeCompletion ( false ) ;
349
+ expect ( exitSpy ) . toHaveBeenCalledWith ( 1 , process . platform , process . version , process . exit , require ( 'exit' ) ) ;
404
350
} ) ;
405
351
} ) ;
406
352
} ) ;
0 commit comments