Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

catch all branches by adding window width tests

Craig Taub763698ce5cba
diff --git a/test/reporters/dot.spec.js b/test/reporters/dot.spec.js
index 5576065e..7dabdfc5 100644
--- a/test/reporters/dot.spec.js
+++ b/test/reporters/dot.spec.js
@@ -9,6 +9,7 @@ describe('Dot reporter', function () {
var stdoutWrite;
var runner;
var useColors;
+ var windowWidth;
beforeEach(function () {
stdout = [];
@@ -18,11 +19,14 @@ describe('Dot reporter', function () {
stdout.push(string);
};
useColors = Base.useColors;
+ windowWidth = Base.window.width;
Base.useColors = false;
+ Base.window.width = 0;
});
afterEach(function () {
Base.useColors = useColors;
+ Base.window.width = windowWidth;
});
describe('on start', function () {
@@ -41,30 +45,121 @@ describe('Dot reporter', function () {
});
});
describe('on pending', function () {
- it('should return a new line and a coma', function () {
- runner.on = function (event, callback) {
- if (event === 'pending') {
- callback();
- }
- };
- Dot.call({epilogue: function () {}}, runner);
- process.stdout.write = stdoutWrite;
- var expectedArray = [
- '\n ',
- Base.symbols.comma
- ];
- stdout.should.deepEqual(expectedArray);
+ describe('if window width is greater than 1', function () {
+ beforeEach(function () {
+ Base.window.width = 2;
+ });
+ it('should return a new line and then a coma', function () {
+ runner.on = function (event, callback) {
+ if (event === 'pending') {
+ callback();
+ }
+ };
+ Dot.call({epilogue: function () {}}, runner);
+ process.stdout.write = stdoutWrite;
+ var expectedArray = [
+ '\n ',
+ Base.symbols.comma
+ ];
+ stdout.should.deepEqual(expectedArray);
+ });
+ });
+ describe('if window width is equal to or less than 1', function () {
+ it('should return a coma', function () {
+ runner.on = function (event, callback) {
+ if (event === 'pending') {
+ callback();
+ }
+ };
+ Dot.call({epilogue: function () {}}, runner);
+ process.stdout.write = stdoutWrite;
+ var expectedArray = [
+ Base.symbols.comma
+ ];
+ stdout.should.deepEqual(expectedArray);
+ });
});
});
describe('on pass', function () {
- describe('if test speed is fast', function () {
- it('should return a new line and a dot', function () {
+ describe('if window width is greater than 1', function () {
+ beforeEach(function () {
+ Base.window.width = 2;
+ });
+ describe('if test speed is fast', function () {
+ it('should return a new line and then a dot', function () {
+ var test = {
+ duration: 1,
+ slow: function () { return 2; }
+ };
+ runner.on = function (event, callback) {
+ if (event === 'pass') {
+ callback(test);
+ }
+ };
+ Dot.call({epilogue: function () {}}, runner);
+ process.stdout.write = stdoutWrite;
+ var expectedArray = [
+ '\n ',
+ Base.symbols.dot
+ ];
+ stdout.should.deepEqual(expectedArray);
+ });
+ });
+ });
+ describe('if window width is equal to or less than 1', function () {
+ describe('if test speed is fast', function () {
+ it('should return a dot', function () {
+ var test = {
+ duration: 1,
+ slow: function () { return 2; }
+ };
+ runner.on = function (event, callback) {
+ if (event === 'pass') {
+ callback(test);
+ }
+ };
+ Dot.call({epilogue: function () {}}, runner);
+ process.stdout.write = stdoutWrite;
+ var expectedArray = [
+ Base.symbols.dot
+ ];
+ stdout.should.deepEqual(expectedArray);
+ });
+ });
+ describe('if test speed is slow', function () {
+ it('should return a dot', function () {
+ var test = {
+ duration: 2,
+ slow: function () { return 1; }
+ };
+ runner.on = function (event, callback) {
+ if (event === 'pass') {
+ callback(test);
+ }
+ };
+ Dot.call({epilogue: function () {}}, runner);
+ process.stdout.write = stdoutWrite;
+ var expectedArray = [
+ Base.symbols.dot
+ ];
+ stdout.should.deepEqual(expectedArray);
+ });
+ });
+ });
+ });
+ describe('on fail', function () {
+ describe('if window width is greater than 1', function () {
+ beforeEach(function () {
+ Base.window.width = 2;
+ });
+ it('should return a new line and then an exclamation mark', function () {
var test = {
- duration: 1,
- slow: function () { return 2; }
+ test: {
+ err: 'some error'
+ }
};
runner.on = function (event, callback) {
- if (event === 'pass') {
+ if (event === 'fail') {
callback(test);
}
};
@@ -72,53 +167,32 @@ describe('Dot reporter', function () {
process.stdout.write = stdoutWrite;
var expectedArray = [
'\n ',
- Base.symbols.dot
+ Base.symbols.bang
];
stdout.should.deepEqual(expectedArray);
});
});
- describe('if test speed is slow', function () {
- it('should return a new line and a dot', function () {
+ describe('if window width is equal to or less than 1', function () {
+ it('should return an exclamation mark', function () {
var test = {
- duration: 2,
- slow: function () { return 1; }
+ test: {
+ err: 'some error'
+ }
};
runner.on = function (event, callback) {
- if (event === 'pass') {
+ if (event === 'fail') {
callback(test);
}
};
Dot.call({epilogue: function () {}}, runner);
process.stdout.write = stdoutWrite;
var expectedArray = [
- '\n ',
- Base.symbols.dot
+ Base.symbols.bang
];
stdout.should.deepEqual(expectedArray);
});
});
});
- describe('on fail', function () {
- it('should return a new line and a exclamation mark', function () {
- var test = {
- test: {
- err: 'some error'
- }
- };
- runner.on = function (event, callback) {
- if (event === 'fail') {
- callback(test);
- }
- };
- Dot.call({epilogue: function () {}}, runner);
- process.stdout.write = stdoutWrite;
- var expectedArray = [
- '\n ',
- Base.symbols.bang
- ];
- stdout.should.deepEqual(expectedArray);
- });
- });
describe('on end', function () {
it('should call the epilogue', function () {
runner.on = function (event, callback) {