Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mightyaleksey committed Nov 2, 2015
1 parent cd01a98 commit 60418c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
: '';

Expand Down
9 changes: 7 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});

0 comments on commit 60418c5

Please sign in to comment.