From 60418c56e2508d3ac0990f459aaea55a50b078d0 Mon Sep 17 00:00:00 2001 From: Alexey Litvinov Date: Mon, 2 Nov 2015 22:14:22 +0300 Subject: [PATCH] bug fix --- index.js | 2 +- test.js | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 5c62ea3..5ba7b3c 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,7 @@ module.exports = function createGenerator(pattern, options) { var context = options && typeof options.context === 'string' ? options.context : ''; - var hashPrefix = options && typeof options.hashPrefix + var hashPrefix = options && typeof options.hashPrefix === 'string' ? options.hashPrefix : ''; diff --git a/test.js b/test.js index e48f549..32d66db 100644 --- a/test.js +++ b/test.js @@ -6,11 +6,16 @@ describe('generic-names', function () { it('should use cwd if no context provided', function () { var generate = genericNames('[name]__[local]___[hash:base64:5]'); - assert.equal(generate('foo', '/test/case/source.css'), 'source__foo___2bpA4'); + assert.equal(generate('foo', '/test/case/source.css'), 'source__foo___2e670'); }); it('should generate another hash for the provided context', function () { var generate = genericNames('[name]__[local]___[hash:base64:5]', {context: '/test'}); - assert.equal(generate('foo', '/test/case/source.css'), 'source__foo___CEQPZ'); + assert.equal(generate('foo', '/test/case/source.css'), 'source__foo___19xFw'); + }); + + it('should generate another hash for the provided hashPrefix', function () { + var generate = genericNames('[name]__[local]___[hash:base64:5]', {context: '/test', hashPrefix: '--'}); + assert.equal(generate('foo', '/test/case/source.css'), 'source__foo___3T0Un'); }); });