diff --git a/deno.json b/deno.json index 2a2365cd..f944fb6e 100644 --- a/deno.json +++ b/deno.json @@ -12,7 +12,7 @@ "exclude": ["CHANGELOG.md"] }, "lint": { - "exclude": ["tests/"], + "exclude": ["test/"], "rules": { "include": [ "no-sync-fn-in-async-fn" diff --git a/lib/file_test.ts b/lib/file_test.ts index f865f751..a35151c0 100644 --- a/lib/file_test.ts +++ b/lib/file_test.ts @@ -18,7 +18,7 @@ import { URI } from "./uri.ts"; describe("collect", () => { it("direct import", async () => { const results = FileUpdate.collect( - await DependencyUpdate.collect("./tests/direct-import/mod.ts"), + await DependencyUpdate.collect("./test/fixtures/direct-import/mod.ts"), ); assertEquals(results.length, 2); }); @@ -26,8 +26,8 @@ describe("collect", () => { it("import map", async () => { const results = FileUpdate.collect( await DependencyUpdate.collect( - "./tests/import-map/mod.ts", - { importMap: "./tests/import-map/deno.json" }, + "./test/fixtures/import-map/mod.ts", + { importMap: "./test/fixtures/import-map/deno.json" }, ), ); assertEquals(results.length, 2); @@ -44,8 +44,8 @@ describe("collect", () => { it("import map with no resolve", async () => { const results = FileUpdate.collect( await DependencyUpdate.collect( - "./tests/import-map-no-resolve/mod.ts", - { importMap: "./tests/import-map-no-resolve/deno.json" }, + "./test/fixtures/import-map-no-resolve/mod.ts", + { importMap: "./test/fixtures/import-map-no-resolve/deno.json" }, ), ); assertEquals(results.length, 1); @@ -75,32 +75,34 @@ describe("writeAll", () => { it("direct import", async () => { const results = FileUpdate.collect( - await DependencyUpdate.collect("./tests/direct-import/mod.ts"), + await DependencyUpdate.collect("./test/fixtures/direct-import/mod.ts"), ); FileUpdate.writeAll(results); - assertExists(output.get(URI.from("tests/direct-import/mod.ts"))); - assertExists(output.get(URI.from("tests/direct-import/lib.ts"))); + assertExists(output.get(URI.from("test/fixtures/direct-import/mod.ts"))); + assertExists(output.get(URI.from("test/fixtures/direct-import/lib.ts"))); }); it("import map", async () => { const results = FileUpdate.collect( await DependencyUpdate.collect( - "./tests/import-map/mod.ts", - { importMap: "./tests/import-map/deno.json" }, + "./test/fixtures/import-map/mod.ts", + { importMap: "./test/fixtures/import-map/deno.json" }, ), ); FileUpdate.writeAll(results); - assertExists(output.get(URI.from("tests/import-map/deno.json"))); + assertExists(output.get(URI.from("test/fixtures/import-map/deno.json"))); }); it("import map with no resolve", async () => { const results = FileUpdate.collect( await DependencyUpdate.collect( - "./tests/import-map-no-resolve/mod.ts", - { importMap: "./tests/import-map-no-resolve/deno.json" }, + "./test/fixtures/import-map-no-resolve/mod.ts", + { importMap: "./test/fixtures/import-map-no-resolve/deno.json" }, ), ); FileUpdate.writeAll(results); - assertExists(output.get(URI.from("tests/import-map-no-resolve/mod.ts"))); + assertExists( + output.get(URI.from("test/fixtures/import-map-no-resolve/mod.ts")), + ); }); }); diff --git a/lib/git_test.ts b/lib/git_test.ts index 55903224..6e76a510 100644 --- a/lib/git_test.ts +++ b/lib/git_test.ts @@ -41,7 +41,9 @@ describe("commitAll()", () => { let readTextFileSyncStub: Stub; beforeAll(async () => { - updates = await DependencyUpdate.collect("./tests/direct-import/mod.ts"); + updates = await DependencyUpdate.collect( + "./test/fixtures/direct-import/mod.ts", + ); writeTextFileSyncStub = stub( Deno, "writeTextFileSync", @@ -72,8 +74,8 @@ describe("commitAll()", () => { beforeEach(() => { for ( const file of [ - "./tests/direct-import/mod.ts", - "./tests/direct-import/lib.ts", + "./test/fixtures/direct-import/mod.ts", + "./test/fixtures/direct-import/lib.ts", ] ) { const content = readTextFileSyncOriginal(file); @@ -107,11 +109,11 @@ describe("commitAll()", () => { assertArrayIncludes( DenoCommandStub.commands, [ - "git add tests/direct-import/mod.ts", + "git add test/fixtures/direct-import/mod.ts", 'git commit -m "build(deps): update node-emoji"', - "git add tests/direct-import/mod.ts", + "git add test/fixtures/direct-import/mod.ts", 'git commit -m "build(deps): update deno.land/x/deno_graph"', - // "git add tests/direct-import/mod.ts tests/direct-import/lib.ts", + // "git add test/fixtures/direct-import/mod.ts test/fixtures/direct-import/lib.ts", 'git commit -m "build(deps): update deno.land/std"', ], ); @@ -126,10 +128,10 @@ describe("commitAll()", () => { assertArrayIncludes( DenoCommandStub.commands, [ - "git add tests/direct-import/mod.ts", - 'git commit -m "build(deps): update tests/direct-import/mod.ts"', - "git add tests/direct-import/lib.ts", - 'git commit -m "build(deps): update tests/direct-import/lib.ts"', + "git add test/fixtures/direct-import/mod.ts", + 'git commit -m "build(deps): update test/fixtures/direct-import/mod.ts"', + "git add test/fixtures/direct-import/lib.ts", + 'git commit -m "build(deps): update test/fixtures/direct-import/lib.ts"', ], ); }); diff --git a/lib/import_map_test.ts b/lib/import_map_test.ts index b711c555..46dbd4ab 100644 --- a/lib/import_map_test.ts +++ b/lib/import_map_test.ts @@ -15,20 +15,23 @@ describe("readFromJson()", () => { assertEquals(importMap, undefined); await Deno.remove(f); }); - it("tests/import-map/deno.json", async () => { + it("test/fixtures/import-map/deno.json", async () => { const importMap = await ImportMap.readFromJson( - new URL("../tests/import-map/deno.json", import.meta.url), + new URL("../test/fixtures/import-map/deno.json", import.meta.url), ); assertExists(importMap); }); - it("tests/import-map-referred/import_map.json", async () => { + it("test/fixtures/import-map-referred/import_map.json", async () => { const importMap = await ImportMap.readFromJson( - new URL("../tests/import-map-referred/deno.json", import.meta.url), + new URL( + "../test/fixtures/import-map-referred/deno.json", + import.meta.url, + ), ); assertExists(importMap); assertEquals( importMap.specifier, - URI.from("./tests/import-map-referred/import_map.json"), + URI.from("./test/fixtures/import-map-referred/import_map.json"), ); }); }); @@ -36,10 +39,10 @@ describe("readFromJson()", () => { describe("resolve()", () => { it("resolve specifiers in import maps", async () => { const importMap = await ImportMap.readFromJson( - new URL("../tests/import-map/deno.json", import.meta.url), + new URL("../test/fixtures/import-map/deno.json", import.meta.url), ); assertExists(importMap); - const referrer = URI.from("tests/import-map/mod.ts"); + const referrer = URI.from("test/fixtures/import-map/mod.ts"); assertEquals( importMap.resolve("std/version.ts", referrer), { @@ -67,19 +70,19 @@ describe("resolve()", () => { assertEquals( importMap.resolve("/lib.ts", referrer), { - specifier: URI.from("tests/import-map/lib.ts"), + specifier: URI.from("test/fixtures/import-map/lib.ts"), }, ); }); it("do not resolve an url", async () => { const importMap = await ImportMap.readFromJson( new URL( - "../tests/import-map-no-resolve/deno.json", + "../test/fixtures/import-map-no-resolve/deno.json", import.meta.url, ), ); assertExists(importMap); - const referrer = URI.from("tests/import-map-no-resolve/deps.ts"); + const referrer = URI.from("test/fixtures/import-map-no-resolve/deps.ts"); assertEquals( importMap.resolve( "https://deno.land/std@0.171.0/testing/asserts.ts", @@ -90,10 +93,13 @@ describe("resolve()", () => { }); it("resolve specifiers in a referred import map", async () => { const importMap = await ImportMap.readFromJson( - new URL("../tests/import-map-referred/deno.json", import.meta.url), + new URL( + "../test/fixtures/import-map-referred/deno.json", + import.meta.url, + ), ); assertExists(importMap); - const referrer = URI.from("tests/import-map-referred/mod.ts"); + const referrer = URI.from("test/fixtures/import-map-referred/mod.ts"); assertEquals( importMap.resolve("dax", referrer), { @@ -109,15 +115,18 @@ describe("resolveSimple()", () => { let importMap: ImportMap; beforeAll(async () => { const maybe = await ImportMap.readFromJson( - new URL("../tests/import-map/deno.json", import.meta.url), + new URL("../test/fixtures/import-map/deno.json", import.meta.url), ); assertExists(maybe); importMap = maybe; }); it("resolve an absolute path", () => { assertEquals( - importMap.resolveSimple("/lib.ts", URI.from("tests/import-map/mod.ts")), - URI.from("tests/import-map/lib.ts"), + importMap.resolveSimple( + "/lib.ts", + URI.from("test/fixtures/import-map/mod.ts"), + ), + URI.from("test/fixtures/import-map/lib.ts"), ); }); }); diff --git a/lib/update_test.ts b/lib/update_test.ts index eaf42e18..4860e9ee 100644 --- a/lib/update_test.ts +++ b/lib/update_test.ts @@ -17,7 +17,7 @@ describe("_create", () => { specifier: "https://deno.land/std@0.1.0/version.ts", // deno-lint-ignore no-explicit-any } as any, - }, URI.from("tests/direct-import/mod.ts")); + }, URI.from("test/fixtures/direct-import/mod.ts")); assertExists(update); }); it("https://deno.land/std - no semver", async () => { @@ -27,7 +27,7 @@ describe("_create", () => { specifier: "https://deno.land/std/version.ts", // deno-lint-ignore no-explicit-any } as any, - }, URI.from("tests/direct-import/mod.ts")); + }, URI.from("test/fixtures/direct-import/mod.ts")); assertEquals(update, undefined); }); it("https://deno.land/x/deno_graph", async () => { @@ -37,7 +37,7 @@ describe("_create", () => { specifier: "https://deno.land/x/deno_graph@0.1.0/mod.ts", // deno-lint-ignore no-explicit-any } as any, - }, URI.from("tests/direct-import/mod.ts")); + }, URI.from("test/fixtures/direct-import/mod.ts")); assertExists(update); }); it("npm:node-emoji", async () => { @@ -47,7 +47,7 @@ describe("_create", () => { specifier: "npm:node-emoji@1.0.0", // deno-lint-ignore no-explicit-any } as any, - }, URI.from("tests/direct-import/mod.ts")); + }, URI.from("test/fixtures/direct-import/mod.ts")); assertExists(update); }); }); @@ -56,7 +56,7 @@ describe("_create - with import map", () => { let importMap: ImportMap; beforeAll(async () => { importMap = (await ImportMap.readFromJson( - new URL("../tests/import-map/deno.json", import.meta.url), + new URL("../test/fixtures/import-map/deno.json", import.meta.url), ))!; }); it("std/version.ts", async () => { @@ -68,7 +68,7 @@ describe("_create - with import map", () => { // deno-lint-ignore no-explicit-any } as any, }, - URI.from("tests/import-map/mod.ts"), + URI.from("test/fixtures/import-map/mod.ts"), { importMap }, ); assertExists(update); @@ -81,9 +81,9 @@ describe("_create - with import map", () => { path: "/version.ts", specifier: "https://deno.land/std@0.200.0/version.ts", code: { specifier: "std/version.ts" }, - referrer: URI.from("tests/import-map/mod.ts"), + referrer: URI.from("test/fixtures/import-map/mod.ts"), map: { - source: URI.from("tests/import-map/deno.json"), + source: URI.from("test/fixtures/import-map/deno.json"), from: "std/", to: "https://deno.land/std@0.200.0/", }, @@ -94,15 +94,15 @@ describe("_create - with import map", () => { describe("collect", () => { it("direct import", async () => { const updates = await DependencyUpdate.collect( - "./tests/direct-import/mod.ts", + "./test/fixtures/direct-import/mod.ts", ); assertEquals(updates.length, 4); }); it("import map", async () => { const updates = await DependencyUpdate.collect( - "./tests/import-map/mod.ts", + "./test/fixtures/import-map/mod.ts", { - importMap: "./tests/import-map/deno.json", + importMap: "./test/fixtures/import-map/deno.json", }, ); assertEquals(updates.length, 4); @@ -114,9 +114,9 @@ describe("applyToModule", () => { let content: string; beforeAll(async () => { updates = await DependencyUpdate.collect( - "./tests/direct-import/mod.ts", + "./test/fixtures/direct-import/mod.ts", ); - content = await Deno.readTextFile("./tests/direct-import/mod.ts"); + content = await Deno.readTextFile("./test/fixtures/direct-import/mod.ts"); }); it("https://deno.land/x/deno_graph", () => { const update = updates.find((update) => @@ -147,10 +147,10 @@ describe("applyToImportMap", () => { let content: string; beforeAll(async () => { updates = await DependencyUpdate.collect( - "./tests/import-map/mod.ts", - { importMap: "tests/import-map/deno.json" }, + "./test/fixtures/import-map/mod.ts", + { importMap: "test/fixtures/import-map/deno.json" }, ); - content = await Deno.readTextFile("tests/import-map/deno.json"); + content = await Deno.readTextFile("test/fixtures/import-map/deno.json"); }); it("deno_graph", () => { const update = updates.find((update) => diff --git a/tests/direct-import/lib.ts b/test/fixtures/direct-import/lib.ts similarity index 100% rename from tests/direct-import/lib.ts rename to test/fixtures/direct-import/lib.ts diff --git a/tests/direct-import/mod.ts b/test/fixtures/direct-import/mod.ts similarity index 100% rename from tests/direct-import/mod.ts rename to test/fixtures/direct-import/mod.ts diff --git a/tests/import-map-no-resolve/deno.json b/test/fixtures/import-map-no-resolve/deno.json similarity index 100% rename from tests/import-map-no-resolve/deno.json rename to test/fixtures/import-map-no-resolve/deno.json diff --git a/tests/import-map-no-resolve/mod.ts b/test/fixtures/import-map-no-resolve/mod.ts similarity index 100% rename from tests/import-map-no-resolve/mod.ts rename to test/fixtures/import-map-no-resolve/mod.ts diff --git a/tests/import-map-referred/deno.json b/test/fixtures/import-map-referred/deno.json similarity index 100% rename from tests/import-map-referred/deno.json rename to test/fixtures/import-map-referred/deno.json diff --git a/tests/import-map-referred/import_map.json b/test/fixtures/import-map-referred/import_map.json similarity index 100% rename from tests/import-map-referred/import_map.json rename to test/fixtures/import-map-referred/import_map.json diff --git a/tests/import-map-referred/mod.ts b/test/fixtures/import-map-referred/mod.ts similarity index 100% rename from tests/import-map-referred/mod.ts rename to test/fixtures/import-map-referred/mod.ts diff --git a/tests/import-map/deno.json b/test/fixtures/import-map/deno.json similarity index 100% rename from tests/import-map/deno.json rename to test/fixtures/import-map/deno.json diff --git a/tests/import-map/lib.ts b/test/fixtures/import-map/lib.ts similarity index 100% rename from tests/import-map/lib.ts rename to test/fixtures/import-map/lib.ts diff --git a/tests/import-map/mod.ts b/test/fixtures/import-map/mod.ts similarity index 100% rename from tests/import-map/mod.ts rename to test/fixtures/import-map/mod.ts