From 18a044f9aec31925980e143695f1880a48178aa4 Mon Sep 17 00:00:00 2001 From: Sergey Belov Date: Tue, 5 Jun 2012 21:23:52 +0300 Subject: [PATCH] Rewrite tests from vows to mocha: util tests See bem/bem-tools#140 --- test/util-test.js | 53 ------------------------------------- test/util.mocha.js | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 53 deletions(-) delete mode 100644 test/util-test.js create mode 100644 test/util.mocha.js diff --git a/test/util-test.js b/test/util-test.js deleted file mode 100644 index 2b540543..00000000 --- a/test/util-test.js +++ /dev/null @@ -1,53 +0,0 @@ -var vows = require('vows'), - assert = require('assert'), - bemUtil = require('../lib/util'), - PATH = require('../lib/path'); - -vows.describe('util').addBatch({ - - 'getBemTechPath() call with param': { - topic: function() { - return bemUtil.getBemTechPath; - }, - "'css' resolves to 'bem/lib/techs/css'": function(topic) { - assert.equal(topic('css'), PATH.unixToOs('bem/lib/techs/css')); - }, - "'custom' resolves to 'bem/lib/tech'": function(topic) { - assert.equal(topic('custom'), PATH.unixToOs('bem/lib/tech')); - } - }, - - 'isRequireable() call with param': { - topic: function() { - return bemUtil.isRequireable; - }, - "'path' returns true": function(topic) { - assert.isTrue(topic('path')); - }, - "'unexistent-module' returns false": function(topic) { - assert.isFalse(topic('unexistent-module')); - } - }, - - 'isPath() call with param': { - topic: function() { - return bemUtil.isPath; - }, - "'/path/to/file' returns true": function(topic) { - assert.isTrue(topic(PATH.unixToOs('/path/to/file'))); - }, - "'./path/to/file' returns true": function(topic) { - assert.isTrue(topic('.' + PATH.unixToOs('/path/to/file'))); - }, - "'path/to/file' returns true": function(topic) { - assert.isTrue(topic(PATH.unixToOs('path/to/file'))); - }, - "'file' returns false": function(topic) { - assert.isFalse(topic('file')); - }, - "'file.ext' returns false": function(topic) { - assert.isFalse(topic('file.ext')); - } - } - -}).export(module); diff --git a/test/util.mocha.js b/test/util.mocha.js new file mode 100644 index 00000000..5da51863 --- /dev/null +++ b/test/util.mocha.js @@ -0,0 +1,66 @@ +var assert = require('chai').assert, + U = require('../lib/util'), + PATH = require('../lib/path'); + +/** + * Mocha BDD interface. + * + * @name describe @function + * @name it @function + * @name before @function + * @name after @function + * @name beforeEach @function + * @name afterEach @function + */ + +describe('util', function() { + + describe('getBemTechPath()', function() { + + it("'css' resolves to 'bem/lib/techs/css'", function() { + assert.equal(U.getBemTechPath('css'), PATH.unixToOs('bem/lib/techs/css')); + }); + + it("'custom' resolves to 'bem/lib/tech'", function() { + assert.equal(U.getBemTechPath('custom'), PATH.unixToOs('bem/lib/tech')); + }); + + }); + + describe('isRequireable()', function() { + + it("'path' returns true", function() { + assert.isTrue(U.isRequireable('path')); + }); + + it("'unexistent-module' returns false", function() { + assert.isFalse(U.isRequireable('unexistent-module')); + }); + + }); + + describe('isPath()', function() { + + it("'/path/to/file' returns true", function() { + assert.isTrue(U.isPath(PATH.unixToOs('/path/to/file'))); + }); + + it("'./path/to/file' returns true", function() { + assert.isTrue(U.isPath('.' + PATH.unixToOs('/path/to/file'))); + }); + + it("'path/to/file' returns true", function() { + assert.isTrue(U.isPath(PATH.unixToOs('path/to/file'))); + }); + + it("'file' returns false", function() { + assert.isFalse(U.isPath('file')); + }); + + it("'file.ext' returns false", function() { + assert.isFalse(U.isPath('file.ext')); + }); + + }); + +});