Skip to content

Commit

Permalink
Add a test to show that computed names work
Browse files Browse the repository at this point in the history
Closes #941
  • Loading branch information
Gerrit0 committed Dec 27, 2023
1 parent e2160f4 commit e23a924
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/converter2/issues/gh941.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const propertyName1 = "p1";
export const propertyName2 = Symbol();

export const Obj = {
[propertyName1]: "foo",
[propertyName2]: "bar",
};
13 changes: 13 additions & 0 deletions src/test/issues.c2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ describe("Issue Tests", () => {
ok(nsFoo.children?.find((r) => r.name === "x"));
});

it("Supports computed names #941", () => {
const project = convert();
const obj = query(project, "Obj");
equal(
obj.type?.visit({
reflection(r) {
return r.declaration.children?.map((c) => c.name);
},
}),
["[propertyName2]", "p1"],
);
});

it("#1124", () => {
const project = convert();
equal(
Expand Down

0 comments on commit e23a924

Please sign in to comment.