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
3 changes: 2 additions & 1 deletion src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"type": "object",
"properties": {
"implementation": {
"description": "The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation)."
"description": "The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation).",
"type": "object"
},
"sassOptions": {
"description": "Options for `node-sass` or `sass` (`Dart Sass`) implementation. (https://github.com/webpack-contrib/sass-loader#implementation).",
Expand Down
13 changes: 10 additions & 3 deletions test/__snapshots__/validate-options.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`validate options 1`] = `
"Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options.implementation should be an object:
object { … }
-> The implementation of the sass to be used (https://github.com/webpack-contrib/sass-loader#implementation)."
`;

exports[`validate options 2`] = `
"Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options.sassOptions should be one of these:
object { … } | function
Expand All @@ -11,7 +18,7 @@ exports[`validate options 1`] = `
* options.sassOptions should be an instance of function."
`;

exports[`validate options 2`] = `
exports[`validate options 3`] = `
"Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options.prependData should be one of these:
string | function
Expand All @@ -21,13 +28,13 @@ exports[`validate options 2`] = `
* options.prependData should be an instance of function."
`;

exports[`validate options 3`] = `
exports[`validate options 4`] = `
"Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options.webpackImporter should be a boolean.
-> Enables/Disables default \`webpack\` importer (https://github.com/webpack-contrib/sass-loader#webpackimporter)."
`;

exports[`validate options 4`] = `
exports[`validate options 5`] = `
"Invalid options object. Sass Loader has been initialised using an options object that does not match the API schema.
- options has an unknown property 'unknown'. These properties are valid:
object { implementation?, sassOptions?, prependData?, sourceMap?, webpackImporter? }"
Expand Down
16 changes: 11 additions & 5 deletions test/validate-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ it('validate options', () => {
'a { color: red; }'
);

// eslint-disable-next-line global-require
// expect(() => validate({ implementation: require('node-sass') })).not.toThrow();
// eslint-disable-next-line global-require
// expect(() => validate({ implementation: require('sass') })).not.toThrow();
// expect(() => validate({ implementation: true })).not.toThrow();
expect(() =>
// eslint-disable-next-line global-require
validate({ implementation: require('node-sass') })
).not.toThrow();
expect(() =>
// eslint-disable-next-line global-require
validate({ implementation: require('sass') })
).not.toThrow();
expect(() =>
validate({ implementation: true })
).toThrowErrorMatchingSnapshot();

expect(() => validate({ sassOptions: {} })).not.toThrow();
expect(() =>
Expand Down