Skip to content

Commit

Permalink
test: add edge case test for findStaticImports
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 19, 2023
1 parent a7ed66a commit f0b120b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions test/imports.test.ts
Expand Up @@ -77,6 +77,14 @@ const staticTests = {
specifier: "#components",
},
],
'import type { foo } from "bar"': [
{
type: "static",
defaultImport: "type",
namedImports: { foo: "foo" },
specifier: "bar",
},
],
};

staticTests[
Expand Down Expand Up @@ -149,9 +157,9 @@ describe("findStaticImports", () => {
for (const [input, _results] of Object.entries(staticTests)) {
it(input.replace(/\n/g, "\\n"), () => {
const matches = findStaticImports(input);
const results = Array.isArray(_results) ? _results : [_results];
expect(matches.length).toEqual(results.length);
for (const [index, test] of results.entries()) {
const expected = Array.isArray(_results) ? _results : [_results];
expect(expected.length).toEqual(matches.length);
for (const [index, test] of expected.entries()) {
const match = matches[index];
expect(match.type).to.equal("static");

Expand Down

0 comments on commit f0b120b

Please sign in to comment.