Skip to content

Commit

Permalink
Test for nested computed keys
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Feb 17, 2021
1 parent 448dce5 commit cb2c424
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/babel-traverse/test/scope.js
Expand Up @@ -219,6 +219,24 @@ describe("scope", () => {
.scope.getBinding("a").path.node.init.value,
).toBe("outside");
});

it("when path is in nested within another computed key", () => {
expect(
getPath(
`var a = "outside"; ({ get [ { get [a]() { let a = "inside"; return a; } }.outside ]() { let a = "middle"; return a; } })`,
)
.get("body.1.expression.properties.0.key.object.properties.0.key")
.scope.getBinding("a").path.node.init.value,
).toBe("outside");

expect(
getPath(
`var a = "outside"; class foo { static get [ class { static get [a]() { let a = "inside"; return a; } }.outside ]() { let a = "middle"; return a; } }`,
)
.get("body.1.body.body.0.key.object.body.body.0.key")
.scope.getBinding("a").path.node.init.value,
).toBe("outside");
});
});

it("should not have visibility on parameter bindings", () => {
Expand Down

0 comments on commit cb2c424

Please sign in to comment.