Skip to content

Commit

Permalink
ASTUtils: Add missing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
matz3 committed Sep 19, 2022
1 parent 2681467 commit d5ce05a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/lib/lbt/utils/ASTUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ test("getPropertyKey", (t) => {
// quoted key with dash
const dashedProperties = parseJS("var myVar = {'my-var': 47}").body[0].declarations[0].init.properties;
t.is(ASTUtils.getPropertyKey(dashedProperties[0]), "my-var", "sole property key is 'my-var'");

// SpreadElement (not supported)
const spreadElement = parseJS("var myVar = { ...foo }").body[0].declarations[0].init.properties;
t.is(ASTUtils.getPropertyKey(spreadElement[0]), undefined);

// Computed property key (not supported)
const computedKey = parseJS(`var myVar = { ["foo" + "bar"]: 42 }`).body[0].declarations[0].init.properties;
t.is(ASTUtils.getPropertyKey(computedKey[0]), undefined);
});

test("findOwnProperty", (t) => {
Expand Down

0 comments on commit d5ce05a

Please sign in to comment.