Skip to content

Commit

Permalink
test: 100% coverage (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lombart authored and Belco90 committed Dec 10, 2019
1 parent 7b8c2c6 commit 2b7c731
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/rules/prefer-explicit-assert.js
Expand Up @@ -6,7 +6,7 @@ const ALL_GET_BY_QUERIES = ALL_QUERIES_METHODS.map(
queryMethod => `get${queryMethod}`
);

const isValidQuery = (node, customQueryNames = []) =>
const isValidQuery = (node, customQueryNames) =>
ALL_GET_BY_QUERIES.includes(node.name) ||
customQueryNames.includes(node.name);

Expand Down
11 changes: 0 additions & 11 deletions lib/utils.js
Expand Up @@ -48,18 +48,7 @@ const ALL_QUERIES_COMBINATIONS = [
ASYNC_QUERIES_COMBINATIONS,
];

const findParent = (node, cb) => {
if (cb(node)) {
return node;
} else if (node.parent) {
return findParent(node.parent, cb);
}

return null;
};

module.exports = {
findParent,
getDocsUrl,
SYNC_QUERIES_VARIANTS,
ASYNC_QUERIES_VARIANTS,
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/prefer-explicit-assert.js
Expand Up @@ -68,6 +68,9 @@ ruleTester.run('prefer-explicit-assert', rule, {
{
code: `const a = { foo: getByText('bar') }`,
},
{
code: `queryByText("foo")`,
},
],

invalid: [
Expand Down Expand Up @@ -111,6 +114,16 @@ ruleTester.run('prefer-explicit-assert', rule, {
},
],
})),
// for coverage
{
code: `getByText("foo")`,
options: [{ foo: 'bar' }],
errors: [
{
messageId: 'preferExplicitAssert',
},
],
},
{
code: `getByIcon('foo')`, // custom `getBy` query extended through options
options: [
Expand Down

0 comments on commit 2b7c731

Please sign in to comment.