Skip to content

Commit

Permalink
Refactor lib/__tests__/createLinter.test.js (#5232)
Browse files Browse the repository at this point in the history
This refactoring removes callbacks via Jest `.resolves`.
See also <https://jestjs.io/docs/asynchronous#resolves--rejects>
  • Loading branch information
ybiquitous committed Apr 9, 2021
1 parent 0c7b7c5 commit 5fba7f1
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions lib/__tests__/createLinter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ it('createLinter().getConfigForFile augmented config loads', () => {
const linter = stylelint.createLinter();
const filepath = path.join(__dirname, 'fixtures/getConfigForFile/a/b/foo.css');

return linter.getConfigForFile(filepath).then((result) => {
expect(result).toEqual({
config: {
plugins: [path.join(__dirname, '/fixtures/plugin-warn-about-foo.js')],
rules: {
'block-no-empty': [true],
'plugin/warn-about-foo': ['always'],
},
pluginFunctions: {
'plugin/warn-about-foo': pluginWarnAboutFoo.rule,
},
return expect(linter.getConfigForFile(filepath)).resolves.toEqual({
config: {
plugins: [path.join(__dirname, '/fixtures/plugin-warn-about-foo.js')],
rules: {
'block-no-empty': [true],
'plugin/warn-about-foo': ['always'],
},
filepath: path.join(__dirname, 'fixtures/getConfigForFile/a/.stylelintrc'),
});
pluginFunctions: {
'plugin/warn-about-foo': pluginWarnAboutFoo.rule,
},
},
filepath: path.join(__dirname, 'fixtures/getConfigForFile/a/.stylelintrc'),
});
});

Expand All @@ -32,12 +30,12 @@ it('createLinter().isPathIgnored', () => {
};
const linter = stylelint.createLinter({ config });

return Promise.all([
linter.isPathIgnored('a.css'),
linter.isPathIgnored('foo/bar/baz.css'),
linter.isPathIgnored('foo/bar/baz.scss'),
linter.isPathIgnored('foo/invalid-hex.css'),
]).then((results) => {
expect(results).toEqual([true, true, false, false]);
});
return expect(
Promise.all([
linter.isPathIgnored('a.css'),
linter.isPathIgnored('foo/bar/baz.css'),
linter.isPathIgnored('foo/bar/baz.scss'),
linter.isPathIgnored('foo/invalid-hex.css'),
]),
).resolves.toEqual([true, true, false, false]);
});

0 comments on commit 5fba7f1

Please sign in to comment.