Skip to content

Commit b92263b

Browse files
committed
simple tests
1 parent 55c8cf7 commit b92263b

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.git*
2+
.travis.yml
3+
test.js

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Helper for building generic names, similar to webpack",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "mocha"
88
},
99
"repository": {
1010
"type": "git",
@@ -22,5 +22,8 @@
2222
"homepage": "https://github.com/sullenor/generic-names#readme",
2323
"dependencies": {
2424
"loader-utils": "^0.2.11"
25+
},
26+
"devDependencies": {
27+
"mocha": "^2.3.3"
2528
}
2629
}

readme.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ Helper for building generic names, similar to webpack. Designed to be used with
77

88
```javascript
99
var genericNames = require('generic-names');
10-
var fn = genericNames('[name]__[local]___[hash:base64:5]', {
10+
var generate = genericNames('[name]__[local]___[hash:base64:5]', {
1111
context: process.cwd()
1212
});
13+
14+
generate('foo', '/case/source.css'); // 'source__foo___3mRq8'
1315
```

test.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
describe('generic-names', function () {
2+
'use strict';
3+
4+
var assert = require('assert');
5+
var genericNames = require('.');
6+
7+
it('should use cwd if no context provided', function () {
8+
var generate = genericNames('[name]__[local]___[hash:base64:5]');
9+
assert.equal(generate('foo', '/test/case/source.css'), 'source__foo___2bpA4');
10+
});
11+
12+
it('should generate another hash for the provided context', function () {
13+
var generate = genericNames('[name]__[local]___[hash:base64:5]', {context: '/test'});
14+
assert.equal(generate('foo', '/test/case/source.css'), 'source__foo___CEQPZ');
15+
});
16+
});

0 commit comments

Comments
 (0)