Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rules): add .concurrent support (#498) #502

Merged
merged 6 commits into from
Jan 4, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(utils): inline isConcurrentTestCase
  • Loading branch information
G-Rath committed Jan 4, 2020
commit fb43b715ed12552b37211e71a70a3336cd470bd4
26 changes: 6 additions & 20 deletions src/rules/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,34 +632,20 @@ export const isHook = (
);
};

const isConcurrentTestCase = (
node: TSESTree.CallExpression,
): node is JestFunctionCallExpression<TestCaseName> => {
console.log(node);
return (
node.callee.type === AST_NODE_TYPES.MemberExpression &&
node.callee.object.type === AST_NODE_TYPES.MemberExpression &&
TestCaseName.hasOwnProperty(
((node.callee.object as TSESTree.MemberExpression)
.object as TSESTree.Identifier).name,
) &&
node.callee.property.type === AST_NODE_TYPES.Identifier &&
TestCaseProperty.hasOwnProperty(node.callee.property.name)
);
};

export const isTestCase = (
node: TSESTree.CallExpression,
): node is JestFunctionCallExpression<TestCaseName> => {
return (
(node.callee.type === AST_NODE_TYPES.Identifier &&
TestCaseName.hasOwnProperty(node.callee.name)) ||
(node.callee.type === AST_NODE_TYPES.MemberExpression &&
node.callee.object.type === AST_NODE_TYPES.Identifier &&
TestCaseName.hasOwnProperty(node.callee.object.name) &&
node.callee.property.type === AST_NODE_TYPES.Identifier &&
TestCaseProperty.hasOwnProperty(node.callee.property.name)) ||
isConcurrentTestCase(node)
TestCaseProperty.hasOwnProperty(node.callee.property.name) &&
((node.callee.object.type === AST_NODE_TYPES.Identifier &&
TestCaseName.hasOwnProperty(node.callee.object.name)) ||
(node.callee.object.type === AST_NODE_TYPES.MemberExpression &&
node.callee.object.object.type === AST_NODE_TYPES.Identifier &&
TestCaseName.hasOwnProperty(node.callee.object.object.name))))
);
};

Expand Down