From f0b120b21825619e9d63e9f536b62188b97ee203 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 19 Jun 2023 14:23:41 +0200 Subject: [PATCH] test: add edge case test for `findStaticImports` --- test/imports.test.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/imports.test.ts b/test/imports.test.ts index cfe683c..7512ea0 100644 --- a/test/imports.test.ts +++ b/test/imports.test.ts @@ -77,6 +77,14 @@ const staticTests = { specifier: "#components", }, ], + 'import type { foo } from "bar"': [ + { + type: "static", + defaultImport: "type", + namedImports: { foo: "foo" }, + specifier: "bar", + }, + ], }; staticTests[ @@ -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");