Skip to content

Commit 60919f6

Browse files
lukeapageSimenB
authored andcommittedNov 6, 2018
fix(valid-expect-in-promise): fix type exception
Fixes #195
1 parent 02cd21a commit 60919f6

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎rules/__tests__/valid-expect-in-promise.test.js

+9
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ ruleTester.run('valid-expect-in-promise', rule, {
182182
],
183183

184184
valid: [
185+
`
186+
it('it1', () => new Promise((done) => {
187+
test()
188+
.then(() => {
189+
expect(someThing).toEqual(true);
190+
done();
191+
});
192+
}));
193+
`,
185194
`
186195
it('it1', () => {
187196
return somePromise.then(() => {

‎rules/valid-expect-in-promise.js

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const getTestFunction = node => {
8888
const isParentThenOrPromiseReturned = (node, testFunctionBody) => {
8989
return (
9090
testFunctionBody.type === 'CallExpression' ||
91+
testFunctionBody.type === 'NewExpression' ||
9192
node.parent.parent.type === 'ReturnStatement' ||
9293
isPromiseReturnedLater(node, testFunctionBody) ||
9394
isThenOrCatch(node.parent.parent)

0 commit comments

Comments
 (0)
Please sign in to comment.