Skip to content
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
32 changes: 32 additions & 0 deletions test/__snapshots__/sassOptions-option.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`sassOptions option should work when the option is empty "Object" (dart-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option is empty "Object" (dart-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option is empty "Object" (dart-sass) (scss): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option is empty "Object" (dart-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option is empty "Object" (node-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option is empty "Object" (node-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option is empty "Object" (node-sass) (scss): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option is empty "Object" (node-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" (dart-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" (dart-sass) (sass): warnings 1`] = `Array []`;
Expand All @@ -16,6 +32,22 @@ exports[`sassOptions option should work when the option like "Function" (node-sa

exports[`sassOptions option should work when the option like "Function" (node-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (dart-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (dart-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (dart-sass) (scss): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (dart-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (node-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (node-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (node-sass) (scss): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Function" and never return (node-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Object" (dart-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work when the option like "Object" (dart-sass) (sass): warnings 1`] = `Array []`;
Expand Down
2 changes: 1 addition & 1 deletion test/helpers/getCodeFromSass.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function getCodeFromSass(testId, options) {
let sassOptions = options.sassOptions || {};

if (typeof sassOptions === 'function') {
sassOptions = sassOptions({ mock: true });
sassOptions = sassOptions({ mock: true }) || {};
}

const { implementation } = loaderOptions;
Expand Down
36 changes: 36 additions & 0 deletions test/sassOptions-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ describe('sassOptions option', () => {
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it(`should work when the option is empty "Object" (${implementationName}) (${syntax})`, async () => {
const testId = getTestId('language', syntax);
const options = {
implementation: getImplementationByName(implementationName),
sassOptions: {},
};
const stats = await compile(testId, { loader: { options } });

expect(getCodeFromBundle(stats).css).toBe(
getCodeFromSass(testId, options).css
);

expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it(`should work when the option like "Function" (${implementationName}) (${syntax})`, async () => {
expect.assertions(5);

Expand All @@ -66,6 +82,26 @@ describe('sassOptions option', () => {
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it(`should work when the option like "Function" and never return (${implementationName}) (${syntax})`, async () => {
expect.assertions(5);

const testId = getTestId('language', syntax);
const options = {
implementation: getImplementationByName(implementationName),
sassOptions: (loaderContext) => {
expect(loaderContext).toBeDefined();
},
};
const stats = await compile(testId, { loader: { options } });

expect(getCodeFromBundle(stats).css).toBe(
getCodeFromSass(testId, options).css
);

expect(stats.compilation.warnings).toMatchSnapshot('warnings');
expect(stats.compilation.errors).toMatchSnapshot('errors');
});

it(`should work with the "importer" option (${implementationName}) (${syntax})`, async () => {
const testId = getTestId('custom-importer', syntax);
const options = {
Expand Down