-
Notifications
You must be signed in to change notification settings - Fork 915
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Pass sass options to plugin * Rename Sass options -> compilerOptions * Typo * Fix string * Update README
- Loading branch information
Showing
3 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* This test requires mocks which could disrupt other tests | ||
*/ | ||
const path = require('path'); | ||
const mockExeca = jest.fn().mockImplementation(() => Promise.resolve({stdout: '', stderr: ''})); | ||
jest.mock('execa', () => (cmd, args) => mockExeca(cmd, args)); | ||
const plugin = require('../plugin'); | ||
|
||
const MOCK_CONFIG = null; | ||
const MOCK_LOAD = {filePath: path.join(__dirname, 'fixtures', 'scss', 'App.scss'), isDev: false}; | ||
|
||
const tests = [ | ||
{name: 'no options', given: {}, expect: []}, | ||
{ | ||
name: 'string option', | ||
given: {compilerOptions: {style: 'compressed'}}, | ||
expect: [`--style=compressed`], | ||
}, | ||
{ | ||
name: 'boolean option', | ||
given: {compilerOptions: {sourceMaps: false}}, | ||
expect: [`--no-source-maps`], | ||
}, | ||
{ | ||
name: 'combination', | ||
given: {compilerOptions: {style: 'compressed', sourceMaps: true}}, | ||
expect: [`--style=compressed`, `--source-maps`], | ||
}, | ||
]; | ||
|
||
describe('plugin-sass', () => { | ||
afterEach(() => { | ||
mockExeca.mockClear(); // clear calls between each test | ||
}); | ||
|
||
tests.forEach((t) => { | ||
it(t.name, async () => { | ||
const {load} = plugin(MOCK_CONFIG, t.given); | ||
await load(MOCK_LOAD); | ||
// Note: this test assumes execa is only used once in the entire plugin. | ||
// If execa needs to be used for another purpose, you can filter calls by 'sass' 1st param here | ||
t.expect.forEach((arg) => { | ||
expect(mockExeca.mock.calls[0][1]).toContain(arg); | ||
}); | ||
}); | ||
}); | ||
}); |
b2d7e37
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: