Skip to content

Commit 2b7c731

Browse files
thomaslombartBelco90
authored andcommitted
test: 100% coverage (#53)
1 parent 7b8c2c6 commit 2b7c731

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

lib/rules/prefer-explicit-assert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const ALL_GET_BY_QUERIES = ALL_QUERIES_METHODS.map(
66
queryMethod => `get${queryMethod}`
77
);
88

9-
const isValidQuery = (node, customQueryNames = []) =>
9+
const isValidQuery = (node, customQueryNames) =>
1010
ALL_GET_BY_QUERIES.includes(node.name) ||
1111
customQueryNames.includes(node.name);
1212

lib/utils.js

-11
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,7 @@ const ALL_QUERIES_COMBINATIONS = [
4848
ASYNC_QUERIES_COMBINATIONS,
4949
];
5050

51-
const findParent = (node, cb) => {
52-
if (cb(node)) {
53-
return node;
54-
} else if (node.parent) {
55-
return findParent(node.parent, cb);
56-
}
57-
58-
return null;
59-
};
60-
6151
module.exports = {
62-
findParent,
6352
getDocsUrl,
6453
SYNC_QUERIES_VARIANTS,
6554
ASYNC_QUERIES_VARIANTS,

tests/lib/rules/prefer-explicit-assert.js

+13
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ ruleTester.run('prefer-explicit-assert', rule, {
6868
{
6969
code: `const a = { foo: getByText('bar') }`,
7070
},
71+
{
72+
code: `queryByText("foo")`,
73+
},
7174
],
7275

7376
invalid: [
@@ -111,6 +114,16 @@ ruleTester.run('prefer-explicit-assert', rule, {
111114
},
112115
],
113116
})),
117+
// for coverage
118+
{
119+
code: `getByText("foo")`,
120+
options: [{ foo: 'bar' }],
121+
errors: [
122+
{
123+
messageId: 'preferExplicitAssert',
124+
},
125+
],
126+
},
114127
{
115128
code: `getByIcon('foo')`, // custom `getBy` query extended through options
116129
options: [

0 commit comments

Comments
 (0)