Skip to content

Commit

Permalink
chore(deps): lock file maintenance (#843)
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored May 25, 2021
1 parent 03bdccb commit 9d89c29
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 94 deletions.
8 changes: 8 additions & 0 deletions src/rules/__tests__/valid-expect-in-promise.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ ruleTester.run('valid-expect-in-promise', rule, {
});
});
`,
dedent`
it('it1', function () {
Promise.resolve().then(/*fulfillment*/ function () {
}, undefined, /*rejection*/ function () {
expect(someThing).toEqual(true)
})
});
`,
dedent`
it('it1', function () {
return Promise.resolve().then(function () {
Expand Down
4 changes: 3 additions & 1 deletion src/rules/no-mocks-import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ const mocksDirName = '__mocks__';
const isMockPath = (path: string) =>
path.split(posix.sep).includes(mocksDirName);

const isMockImportLiteral = (expression: TSESTree.Expression): boolean =>
const isMockImportLiteral = (
expression: TSESTree.CallExpressionArgument,
): boolean =>
isStringNode(expression) && isMockPath(getStringValue(expression));

export default createRule({
Expand Down
2 changes: 1 addition & 1 deletion src/rules/no-test-return-statement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
isTestCaseCall,
} from './utils';

const getBody = (args: TSESTree.Expression[]) => {
const getBody = (args: TSESTree.CallExpressionArgument[]) => {
const [, secondArg] = args;

if (
Expand Down
2 changes: 1 addition & 1 deletion src/rules/prefer-todo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
isTestCaseCall,
} from './utils';

function isEmptyFunction(node: TSESTree.Expression) {
function isEmptyFunction(node: TSESTree.CallExpressionArgument) {
if (!isFunction(node)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/rules/valid-describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { createRule, getNodeName, isDescribeCall, isFunction } from './utils';

const paramsLocation = (
params: TSESTree.Expression[] | TSESTree.Parameter[],
params: TSESTree.CallExpressionArgument[] | TSESTree.Parameter[],
) => {
const [first] = params;
const last = params[params.length - 1];
Expand Down
10 changes: 2 additions & 8 deletions src/rules/valid-expect-in-promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,8 @@ const isParentThenOrPromiseReturned = (
node.type === AST_NODE_TYPES.ReturnStatement ||
isPromiseReturnedLater(node, testFunctionBody);

type PromiseCallbacks = [
TSESTree.Expression | undefined,
TSESTree.Expression | undefined,
];

const verifyExpectWithReturn = (
promiseCallbacks: PromiseCallbacks,
promiseCallbacks: Array<TSESTree.CallExpressionArgument | undefined>,
node: CalledKnownMemberExpression<'then' | 'catch'>,
context: RuleContext,
testFunctionBody: TSESTree.Statement[],
Expand Down Expand Up @@ -187,14 +182,13 @@ export default createRule<unknown[], MessageIds>({
}

const testFunctionBody = body.body;
const [fulfillmentCallback, rejectionCallback] = node.arguments;

// then block can have two args, fulfillment & rejection
// then block can have one args, fulfillment
// catch block can have one args, rejection
// ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
verifyExpectWithReturn(
[fulfillmentCallback, rejectionCallback],
node.arguments.slice(0, 2),
node.callee,
context,
testFunctionBody,
Expand Down
Loading

0 comments on commit 9d89c29

Please sign in to comment.