Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 19 additions & 2 deletions src/rules/tsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ export enum HookName {
'afterEach' = 'afterEach',
}

export enum DescribeProperty {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to export them, but meh

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've just tried to be consistent with all of the rest, but you are right, it is not necessary at the moment.

'each' = 'each',
'only' = 'only',
'skip' = 'skip',
}

export enum TestCaseProperty {
'each' = 'each',
'only' = 'only',
'skip' = 'skip',
'todo' = 'todo',
}

export type JestFunctionName = DescribeAlias | TestCaseName | HookName;

export interface JestFunctionIdentifier<FunctionName extends JestFunctionName>
Expand Down Expand Up @@ -178,7 +191,9 @@ export const isTestCase = (
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))
TestCaseName.hasOwnProperty(node.callee.object.name) &&
node.callee.property.type === AST_NODE_TYPES.Identifier &&
TestCaseProperty.hasOwnProperty(node.callee.property.name))
);
};

Expand All @@ -190,7 +205,9 @@ export const isDescribe = (
DescribeAlias.hasOwnProperty(node.callee.name)) ||
(node.callee.type === AST_NODE_TYPES.MemberExpression &&
node.callee.object.type === AST_NODE_TYPES.Identifier &&
DescribeAlias.hasOwnProperty(node.callee.object.name))
DescribeAlias.hasOwnProperty(node.callee.object.name) &&
node.callee.property.type === AST_NODE_TYPES.Identifier &&
DescribeProperty.hasOwnProperty(node.callee.property.name))
);
};

Expand Down
2 changes: 2 additions & 0 deletions src/rules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export const isTestCase = node =>
(node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
testCaseNames.has(node.callee.object.name) &&
node.callee.property.type === 'Identifier' &&
testCaseProperties.has(node.callee.property.name)));

export const isDescribe = node =>
Expand All @@ -122,6 +123,7 @@ export const isDescribe = node =>
(node.callee.type === 'MemberExpression' &&
node.callee.object.type === 'Identifier' &&
describeAliases.has(node.callee.object.name) &&
node.callee.property.type === 'Identifier' &&
describeProperties.has(node.callee.property.name)));

export const isFunction = node =>
Expand Down