From 22c83474445c012477de0930698cf35a8b28b80d Mon Sep 17 00:00:00 2001 From: anton Date: Wed, 22 Jul 2015 11:06:05 +0300 Subject: [PATCH] Fix an issue and add relevant tests when describe and xdescribe fail when not supplied with a callback (issue #1744). --- .../fixtures/suite/describe.callback.js | 1 + .../fixtures/suite/xdescribe.callback.js | 1 + test/integration/suite.js | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 test/integration/fixtures/suite/describe.callback.js create mode 100644 test/integration/fixtures/suite/xdescribe.callback.js create mode 100644 test/integration/suite.js diff --git a/test/integration/fixtures/suite/describe.callback.js b/test/integration/fixtures/suite/describe.callback.js new file mode 100644 index 0000000000..de55b358a3 --- /dev/null +++ b/test/integration/fixtures/suite/describe.callback.js @@ -0,0 +1 @@ +describe('a suite without a callback'); diff --git a/test/integration/fixtures/suite/xdescribe.callback.js b/test/integration/fixtures/suite/xdescribe.callback.js new file mode 100644 index 0000000000..c5bca84a47 --- /dev/null +++ b/test/integration/fixtures/suite/xdescribe.callback.js @@ -0,0 +1 @@ +xdescribe('a pending suite without a callback'); diff --git a/test/integration/suite.js b/test/integration/suite.js new file mode 100644 index 0000000000..369f08a7ba --- /dev/null +++ b/test/integration/suite.js @@ -0,0 +1,29 @@ +var assert = require('assert'); +var run = require('./helpers').runMocha; +var args = []; + +describe('.describe()', function() { + this.timeout(1000); + it('should throw a helpful error message when a callback for describe is not supplied', function(done) { + run('suite/describe.callback.js', args, function(err, res) { + assert(!err); + pattern = new RegExp('TypeError: a callback is not supplied', 'g'); + var result = res.output.match(pattern) || []; + assert.equal(result.length, 1); + done(); + }); + }); +}); + +describe('.xdescribe()', function() { + this.timeout(1000); + it('should not throw an error when a callback for xdescribe is not supplied', function(done) { + run('suite/xdescribe.callback.js', args, function(err, res) { + assert(!err); + pattern = new RegExp("Error", 'g'); + var result = res.output.match(pattern) || []; + assert.equal(result.length, 0); + done(); + }); + }); +});