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'); }); });