Skip to content

test: camelCase option #814

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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