From f7d0f7d5ebd555426c6e11d0bbabb46d0d1e79c5 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Wed, 29 Apr 2015 01:48:11 +0200 Subject: [PATCH] Refactor type tests. --- test/tests/unit/core/types.js | 38 +++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/test/tests/unit/core/types.js b/test/tests/unit/core/types.js index 7c9524d6..c58e0e62 100644 --- a/test/tests/unit/core/types.js +++ b/test/tests/unit/core/types.js @@ -72,22 +72,30 @@ describe('module \'' + ID + '\'', function () { assert.isFunction(instance.getType); }); - it('works', function () { + _.each([ + ['file.a', 'a'], + ['file.aa', 'a'], + ['foo.b', 'b'], + ['some/path/file.c', 'c'], + ['/some/abs/path/file.c', 'c'], + ['file.x', 'file'], + ['foo', 'file'], + ['some/path/foo', 'file'], + ['/some/path/foo', 'file'], + ['foo/', 'folder'], + ['/', 'folder'], + ['some/path/foo/', 'folder'], + ['/some/path/foo/', 'folder'] + ], function (data) { - var instance = this.applyFn(); - assert.strictEqual(instance.getType('file.a'), 'a'); - assert.strictEqual(instance.getType('file.aa'), 'a'); - assert.strictEqual(instance.getType('foo.b'), 'b'); - assert.strictEqual(instance.getType('some/path/file.c'), 'c'); - assert.strictEqual(instance.getType('/some/abs/path/file.c'), 'c'); - assert.strictEqual(instance.getType('file.x'), 'file'); - assert.strictEqual(instance.getType('foo'), 'file'); - assert.strictEqual(instance.getType('some/path/foo'), 'file'); - assert.strictEqual(instance.getType('/some/path/foo'), 'file'); - assert.strictEqual(instance.getType('foo/'), 'folder'); - assert.strictEqual(instance.getType('/'), 'folder'); - assert.strictEqual(instance.getType('some/path/foo/'), 'folder'); - assert.strictEqual(instance.getType('/some/path/foo/'), 'folder'); + var arg = data[0]; + var exp = data[1]; + + it(arg + ' => ' + exp, function () { + + var instance = this.applyFn(); + assert.strictEqual(instance.getType(arg), exp); + }); }); }); });