Skip to content

Commit 4926f22

Browse files
author
Adam Gruber
committed
Add test for camelCase option
1 parent 3c6a7f6 commit 4926f22

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

test/__snapshots__/test.js.snap

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`sass-extract-js options should NOT convert keys to camelCase when options.camelCase is false 1`] = `
4+
Object {
5+
"MY-VAR": "500px",
6+
"My-Cool_var": "400px",
7+
"my-var": "200px",
8+
"myVar": 0,
9+
"my__var--3": "700px",
10+
"my_other_vAr": "300px",
11+
"my_var": "200px",
12+
"my_var_2": "600px",
13+
}
14+
`;
15+
316
exports[`sass-extract-js should convert basic SASS vars 1`] = `
417
Object {
518
"boolean": true,

test/test.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path');
22
const sassExtract = require('sass-extract');
3-
const js = require('../index');
3+
const createPlugin = require('../lib/plugin');
44

55
const testfiles = {
66
basic: path.resolve(__dirname, './sass/test-basic.scss'),
@@ -10,8 +10,11 @@ const testfiles = {
1010
empty: path.resolve(__dirname, './sass/test-empty.scss'),
1111
};
1212

13-
const getVars = (file, compileOpts = {}) =>
14-
sassExtract.renderSync(Object.assign({}, { file }, compileOpts), { plugins: [js] }).vars;
13+
const getVars = (file, compileOpts = {}, pluginInstance) =>
14+
sassExtract.renderSync(
15+
Object.assign({}, { file }, compileOpts),
16+
{ plugins: [pluginInstance || path.resolve('../sass-extract-js')] },
17+
).vars;
1518

1619
describe('sass-extract-js', () => {
1720
it('should convert basic SASS vars', () => {
@@ -36,4 +39,10 @@ describe('sass-extract-js', () => {
3639
};
3740
expect(getVars(testfiles.sassOpts, opts)).toMatchSnapshot();
3841
});
42+
43+
describe('options', () => {
44+
it('should NOT convert keys to camelCase when options.camelCase is false', () => {
45+
expect(getVars(testfiles.camel, {}, createPlugin({ camelCase: false }))).toMatchSnapshot();
46+
});
47+
});
3948
});

0 commit comments

Comments
 (0)