Skip to content

Commit

Permalink
test: camelCase option (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Nov 27, 2018
1 parent 0bdf9b7 commit b190e51
Show file tree
Hide file tree
Showing 4 changed files with 323 additions and 80 deletions.
202 changes: 202 additions & 0 deletions test/__snapshots__/camelCase-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`camelCase option dashes: errors 1`] = `Array []`;

exports[`camelCase option dashes: locals 1`] = `
Object {
"btn--info_is-disabled_1": "jDvNwV-WRSMB9n2z9QrzR",
"btn-info_is-disabled": "_1XTfjK5gKYeSzbdZhEXRpF",
"btnInfo_isDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
"btnInfo_isDisabled_1": "jDvNwV-WRSMB9n2z9QrzR",
"foo": "bar",
"my-btn-info_is-disabled": "value",
"myBtnInfo_isDisabled": "value",
"simple": "_1penVf9PMtov2qLxmtsMjq",
}
`;

exports[`camelCase option dashes: module (evaluated) 1`] = `
Array [
Array [
1,
"._1XTfjK5gKYeSzbdZhEXRpF {
color: blue;
}
.jDvNwV-WRSMB9n2z9QrzR {
color: blue;
}
._1penVf9PMtov2qLxmtsMjq {
color: red;
}
a {
color: yellow;
}
",
"",
],
]
`;

exports[`camelCase option dashes: warnings 1`] = `Array []`;

exports[`camelCase option dashesOnly: errors 1`] = `Array []`;

exports[`camelCase option dashesOnly: locals 1`] = `
Object {
"btnInfo_isDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
"btnInfo_isDisabled_1": "jDvNwV-WRSMB9n2z9QrzR",
"foo": "bar",
"myBtnInfo_isDisabled": "value",
"simple": "_1penVf9PMtov2qLxmtsMjq",
}
`;

exports[`camelCase option dashesOnly: module (evaluated) 1`] = `
Array [
Array [
1,
"._1XTfjK5gKYeSzbdZhEXRpF {
color: blue;
}
.jDvNwV-WRSMB9n2z9QrzR {
color: blue;
}
._1penVf9PMtov2qLxmtsMjq {
color: red;
}
a {
color: yellow;
}
",
"",
],
]
`;

exports[`camelCase option dashesOnly: warnings 1`] = `Array []`;

exports[`camelCase option not specified: errors 1`] = `Array []`;

exports[`camelCase option not specified: locals 1`] = `
Object {
"btn--info_is-disabled_1": "jDvNwV-WRSMB9n2z9QrzR",
"btn-info_is-disabled": "_1XTfjK5gKYeSzbdZhEXRpF",
"foo": "bar",
"my-btn-info_is-disabled": "value",
"simple": "_1penVf9PMtov2qLxmtsMjq",
}
`;

exports[`camelCase option not specified: module (evaluated) 1`] = `
Array [
Array [
1,
"._1XTfjK5gKYeSzbdZhEXRpF {
color: blue;
}
.jDvNwV-WRSMB9n2z9QrzR {
color: blue;
}
._1penVf9PMtov2qLxmtsMjq {
color: red;
}
a {
color: yellow;
}
",
"",
],
]
`;

exports[`camelCase option not specified: warnings 1`] = `Array []`;

exports[`camelCase option only: errors 1`] = `Array []`;

exports[`camelCase option only: locals 1`] = `
Object {
"btnInfoIsDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
"btnInfoIsDisabled1": "jDvNwV-WRSMB9n2z9QrzR",
"foo": "bar",
"myBtnInfoIsDisabled": "value",
"simple": "_1penVf9PMtov2qLxmtsMjq",
}
`;

exports[`camelCase option only: module (evaluated) 1`] = `
Array [
Array [
1,
"._1XTfjK5gKYeSzbdZhEXRpF {
color: blue;
}
.jDvNwV-WRSMB9n2z9QrzR {
color: blue;
}
._1penVf9PMtov2qLxmtsMjq {
color: red;
}
a {
color: yellow;
}
",
"",
],
]
`;

exports[`camelCase option only: warnings 1`] = `Array []`;

exports[`camelCase option true: errors 1`] = `Array []`;

exports[`camelCase option true: locals 1`] = `
Object {
"btn--info_is-disabled_1": "jDvNwV-WRSMB9n2z9QrzR",
"btn-info_is-disabled": "_1XTfjK5gKYeSzbdZhEXRpF",
"btnInfoIsDisabled": "_1XTfjK5gKYeSzbdZhEXRpF",
"btnInfoIsDisabled1": "jDvNwV-WRSMB9n2z9QrzR",
"foo": "bar",
"my-btn-info_is-disabled": "value",
"myBtnInfoIsDisabled": "value",
"simple": "_1penVf9PMtov2qLxmtsMjq",
}
`;

exports[`camelCase option true: module (evaluated) 1`] = `
Array [
Array [
1,
"._1XTfjK5gKYeSzbdZhEXRpF {
color: blue;
}
.jDvNwV-WRSMB9n2z9QrzR {
color: blue;
}
._1penVf9PMtov2qLxmtsMjq {
color: red;
}
a {
color: yellow;
}
",
"",
],
]
`;

exports[`camelCase option true: warnings 1`] = `Array []`;
101 changes: 101 additions & 0 deletions test/camelCase-option.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
const { webpack, evaluated } = require('./helpers');

describe('camelCase option', () => {
it('true', async () => {
const config = {
loader: {
options: {
modules: true,
camelCase: true,
},
},
};
const testId = './modules/camelCase.css';
const stats = await webpack(testId, config);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);
const evaluatedModule = evaluated(module.source);

expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
expect(evaluatedModule.locals).toMatchSnapshot('locals');
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('not specified', async () => {
const config = { loader: { options: { modules: true } } };
const testId = './modules/camelCase.css';
const stats = await webpack(testId, config);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);
const evaluatedModule = evaluated(module.source);

expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
expect(evaluatedModule.locals).toMatchSnapshot('locals');
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('dashes', async () => {
const config = {
loader: {
options: {
modules: true,
camelCase: 'dashes',
},
},
};
const testId = './modules/camelCase.css';
const stats = await webpack(testId, config);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);
const evaluatedModule = evaluated(module.source);

expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
expect(evaluatedModule.locals).toMatchSnapshot('locals');
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('only', async () => {
const config = {
loader: {
options: {
modules: true,
camelCase: 'only',
},
},
};
const testId = './modules/camelCase.css';
const stats = await webpack(testId, config);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);
const evaluatedModule = evaluated(module.source);

expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
expect(evaluatedModule.locals).toMatchSnapshot('locals');
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it('dashesOnly', async () => {
const config = {
loader: {
options: {
modules: true,
camelCase: 'dashesOnly',
},
},
};
const testId = './modules/camelCase.css';
const stats = await webpack(testId, config);
const { modules } = stats.toJson();
const module = modules.find((m) => m.id === testId);
const evaluatedModule = evaluated(module.source);

expect(evaluatedModule).toMatchSnapshot('module (evaluated)');
expect(evaluatedModule.locals).toMatchSnapshot('locals');
expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});
});
80 changes: 0 additions & 80 deletions test/camelCase.test.js

This file was deleted.

Loading

0 comments on commit b190e51

Please sign in to comment.