Skip to content

Commit

Permalink
chore: table style tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Sep 2, 2021
1 parent eca3e1d commit f2b2184
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions packages/babel-types/test/retrievers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,25 @@ function getBody(program) {

describe("retrievers", function () {
describe("getBindingIdentifiers", function () {
it("variable declarations", function () {
const program = "var a = 1; let b = 2; const c = 3;";
const ids = t.getBindingIdentifiers(getBody(program));
expect(Object.keys(ids)).toEqual(["a", "b", "c"]);
});
it("function declarations", function () {
const program = "var foo = 1; function bar() { var baz = 2; }";
const ids = t.getBindingIdentifiers(getBody(program));
expect(Object.keys(ids)).toEqual(["bar", "foo"]);
});
it("export named declarations", function () {
const program = "export const foo = 'foo';";
const ids = t.getBindingIdentifiers(getBody(program));
expect(Object.keys(ids)).toEqual(["foo"]);
it.each([
[
"variable declarations",
getBody("var a = 1; let b = 2; const c = 3;"),
["a", "b", "c"],
],
[
"function declarations",
getBody("var foo = 1; function bar() { var baz = 2; }"),
["bar", "foo"],
],
[
"export named declarations",
getBody("export const foo = 'foo';"),
["foo"],
],
])("%s", (_, program, bindingNames) => {
const ids = t.getBindingIdentifiers(program);
expect(Object.keys(ids)).toEqual(bindingNames);
});
});
});

0 comments on commit f2b2184

Please sign in to comment.