Skip to content

Commit a985863

Browse files
mightyalekseyAlexey Litvinov
authored andcommitted
falling test for preset
1 parent 2ddce59 commit a985863

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

preset.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const hook = require('.');
22
const lookup = require('lookup-fs');
33

4-
lookup('cmrh.conf.js', (err, cssModulesFilePath) => {
5-
if (err) {
6-
throw new Error('Unable to find css-modules-file.js');
4+
// should it be a sync call?
5+
lookup('cmrh.conf.js', module.parent.filename, (er, cssModulesFilePath) => {
6+
if (er) {
7+
throw new Error('Unable to find cmrh.conf.js');
78
}
89

9-
hook(require(cssModulesFilePath));
10+
const preset = require(cssModulesFilePath);
11+
hook(preset);
1012
});

test/preset/cmrh.conf.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
generateScopedName: '[name]__[local]___[hash:base64:5]',
3+
};

test/preset/fixture/oceanic.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.color
2+
{
3+
background: #1e2a35;
4+
}

test/preset/index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const detachHook = require('../sugar').detachHook;
2+
const dropCache = require('../sugar').dropCache;
3+
4+
suite('css-modules-require-hook/preset', () => {
5+
setup(() => require('../../preset'));
6+
7+
test('should return tokens', () => {
8+
const tokens = require('./fixture/oceanic.css');
9+
assert.deepEqual(tokens, {});
10+
});
11+
12+
teardown(() => {
13+
detachHook('.css');
14+
dropCache('./preset/fixture/oceanic.css');
15+
});
16+
});

0 commit comments

Comments
 (0)