Skip to content

Commit

Permalink
Fix no-setup-in-describe to allow suite config call via computed memb…
Browse files Browse the repository at this point in the history
…er expression
  • Loading branch information
straub committed Sep 10, 2019
1 parent 0d838d5 commit 64d1db4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/util/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function isHookCall(node) {
function isSuiteConfigExpression(node) {
return node.type === 'MemberExpression' &&
node.object.type === 'ThisExpression' &&
suiteConfig.indexOf(node.property.name) !== -1;
suiteConfig.indexOf(getPropertyName(node.property)) !== -1;
}

function isSuiteConfigCall(node) {
Expand Down
13 changes: 2 additions & 11 deletions test/rules/no-setup-in-describe.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ ruleTester.run('no-setup-in-describe', rule, {
'describe("", function () { this.slow(1); it(); })',
'describe("", function () { this.timeout(1); it(); })',
'describe("", function () { this.retries(1); it(); })',
'describe("", function () { this["retries"](1); it(); })',
'describe("", function () { it("", function () { b(); }); })',
'describe("", function () { it("", function () { a.b; }); })',
'describe("", function () { it("", function () { a[b]; }); })',
'describe("", function () { it("", function () { a["b"]; }); })',
'describe("", function () { it("", function () { this.slow(1); }); })',
'describe("", function () { it("", function () { this.timeout(1); }); })',
'describe("", function () { it("", function () { this.retries(1); }); })',
'describe("", function () { it("", function () { this["retries"](1); }); })',
'describe("", function () { function a() { b(); }; it(); })',
'describe("", function () { function a() { b.c; }; it(); })',
'describe("", function () { afterEach(function() { b(); }); it(); })',
Expand Down Expand Up @@ -142,17 +144,6 @@ ruleTester.run('no-setup-in-describe', rule, {
line: 1,
column: 28
} ]
}, {
code: 'describe("", function () { this["retries"](); });',
errors: [ {
message: 'Unexpected function call in describe block.',
line: 1,
column: 28
}, {
message: memberExpressionError,
line: 1,
column: 28
} ]
}, {
code: 'foo("", function () { a.b; });',
settings: {
Expand Down

0 comments on commit 64d1db4

Please sign in to comment.