Skip to content

Commit

Permalink
min reporter 100% coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaub committed Feb 5, 2017
1 parent 64c7051 commit 474a6cb
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/reporters/landing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('Landing reporter', function () {
var runner;
var useColors;
var windowWidth;
var resetCode = '\u001b[0m';

beforeEach(function () {
stdout = [];
Expand Down Expand Up @@ -82,14 +83,15 @@ describe('Landing reporter', function () {

process.stdout.write = stdoutWrite;

var expectedArray = [ '\u001b[1D\u001b[2A',
var expectedArray = [
'\u001b[1D\u001b[2A',
' ',
'\n ',
'',
'✈',
'\n',
' ',
'\u001b[0m'
resetCode
];
stdout.should.deepEqual(expectedArray);
});
Expand All @@ -109,14 +111,15 @@ describe('Landing reporter', function () {

process.stdout.write = stdoutWrite;

var expectedArray = [ '\u001b[1D\u001b[2A',
var expectedArray = [
'\u001b[1D\u001b[2A',
' ',
'\n ',
'',
'✈',
'\n',
' ',
'\u001b[0m'
resetCode
];
stdout.should.deepEqual(expectedArray);
});
Expand Down
56 changes: 56 additions & 0 deletions test/reporters/min.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
'use strict';

var reporters = require('../../').reporters;
var Min = reporters.Min;

describe('Min reporter', function () {
var stdout;
var stdoutWrite;
var runner;

beforeEach(function () {
stdout = [];
runner = {};
stdoutWrite = process.stdout.write;
process.stdout.write = function (string) {
stdout.push(string);
};
});

describe('on start', function () {
it('should clear screen then set cursor position', function () {
runner.on = function (event, callback) {
if (event === 'start') {
callback();
}
};
Min.call({epilogue: function () {}}, runner);

process.stdout.write = stdoutWrite;
var expectedArray = [
'\u001b[2J',
'\u001b[1;3H'
];
stdout.should.deepEqual(expectedArray);
});
});

describe('on end', function () {
it('should call epilogue', function () {
var calledEpilogue = false;
runner.on = function (event, callback) {
if (event === 'end') {
callback();
}
};
Min.call({
epilogue: function () {
calledEpilogue = true;
}
}, runner);
process.stdout.write = stdoutWrite;

calledEpilogue.should.be.true();
});
});
});

0 comments on commit 474a6cb

Please sign in to comment.