-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: workaround missing options validation with jest styleint preset
- Loading branch information
Showing
9 changed files
with
58 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,42 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
const { getTestRule } = require('jest-preset-stylelint'); | ||
const { lint } = require('stylelint'); | ||
|
||
global.testRule = getTestRule({ plugins: ['./src/index.ts'] }); | ||
|
||
global.testOptions = testOptions; | ||
|
||
function testOptions({ ruleName, config, reject }) { | ||
// eslint-disable-next-line no-undef | ||
describe(ruleName, () => { | ||
// eslint-disable-next-line no-undef | ||
it('warn for invalid options', async () => { | ||
const rejections = await Promise.all( | ||
reject.map(async ({ code, message }) => { | ||
const { | ||
results: [{ invalidOptionWarnings }], | ||
} = await lint({ | ||
code, | ||
config: { | ||
plugins: ['./src/index.ts'], | ||
rules: { | ||
[ruleName]: config, | ||
}, | ||
}, | ||
}); | ||
|
||
return { message, invalidOptionWarnings }; | ||
}) | ||
); | ||
|
||
rejections.forEach(({ message, invalidOptionWarnings }) => { | ||
const expectedWarning = { | ||
text: message, | ||
}; | ||
|
||
// eslint-disable-next-line no-undef | ||
expect(invalidOptionWarnings[0]).toMatchObject(expectedWarning); | ||
}); | ||
}); | ||
}); | ||
} |
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
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
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