From 55c806fb7226b1664e4818a8f3dd1953a2cc0b85 Mon Sep 17 00:00:00 2001 From: sthzg Date: Fri, 8 Jul 2016 11:12:51 +0200 Subject: [PATCH] Added unit tests for buildPrefixRegexps() #11 --- test/utils/utilsTest.js | 25 +++++++++++++++++++++++++ utils/utils.js | 1 + 2 files changed, 26 insertions(+) diff --git a/test/utils/utilsTest.js b/test/utils/utilsTest.js index 8ff2a12..1f4d902 100644 --- a/test/utils/utilsTest.js +++ b/test/utils/utilsTest.js @@ -87,6 +87,21 @@ describe('getPkgInfo()', () => { }); +describe('buildPrefixRegexps()', () => { + it('returns expected regexps', function () { + let regexps = utils.buildPrefixRegexps(['contrib-subgen-', 'subgen-'], 'foobar'); + chai.equal(regexps.length, 2); + chai.equal(regexps[0], '/^contrib-subgen-foobar-/'); + chai.equal(regexps[1], '/^subgen-foobar-/'); + }); + + it('returns expected basename for subgen-foobar-helloworld', function () { + let bn = utils.getSubgenBaseName('foobar', ['contrib-subgen-', 'subgen-'], 'subgen-foobar-helloworld'); + chai.equal(bn, 'helloworld'); + }); +}); + + describe('getSubgenBaseName()', () => { it('returns expected basename for contrib-subgen-foobar-helloworld', function () { let bn = utils.getSubgenBaseName('foobar', ['contrib-subgen-', 'subgen-'], 'contrib-subgen-foobar-helloworld'); @@ -98,3 +113,13 @@ describe('getSubgenBaseName()', () => { chai.equal(bn, 'helloworld'); }); }); + + +// TODO +describe('checkActivationState()', () => { +}); + + +// TODO +describe('findExternalSubgens()', () => { +}); diff --git a/utils/utils.js b/utils/utils.js index 119654f..f05304b 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -224,6 +224,7 @@ function sortCharArrByLength(arr, desc=true) { module.exports = { + buildPrefixRegexps, checkActivationState, checkPkgExists, getPkgInfo,