From 57ac1a2f3769a7c4f4a26eb0a1dcd2b852e03aa9 Mon Sep 17 00:00:00 2001 From: hasundue Date: Sat, 21 Oct 2023 22:22:32 +0900 Subject: [PATCH 1/2] refactor: move src/* to lib/ --- cli.ts | 5 +++-- git.ts | 2 +- {src => lib}/dependency.ts | 7 +++---- {src => lib}/dependency_test.ts | 4 ++-- {src => lib}/file.ts | 2 +- {src => lib}/file_test.ts | 6 +++--- {src => lib}/git.ts | 2 +- {src => lib}/git_test.ts | 7 +++---- {src => lib}/import_map.ts | 12 ++++++------ {src => lib}/import_map_test.ts | 6 +++--- {src => lib}/loader.ts | 2 +- {src => lib}/semver.ts | 3 +-- {src => lib}/semver_test.ts | 4 ++-- lib/types.ts | 12 ++++++++++++ {src => lib}/update.ts | 4 ++-- {src => lib}/update_test.ts | 6 +++--- {src => lib}/versions.ts | 6 +++--- {src => lib}/versions_test.ts | 6 +++--- src/types.ts | 13 ------------- 19 files changed, 53 insertions(+), 56 deletions(-) rename {src => lib}/dependency.ts (94%) rename {src => lib}/dependency_test.ts (90%) rename {src => lib}/file.ts (97%) rename {src => lib}/file_test.ts (96%) rename {src => lib}/git.ts (98%) rename {src => lib}/git_test.ts (96%) rename {src => lib}/import_map.ts (87%) rename {src => lib}/import_map_test.ts (95%) rename {src => lib}/loader.ts (94%) rename {src => lib}/semver.ts (87%) rename {src => lib}/semver_test.ts (76%) rename {src => lib}/update.ts (98%) rename {src => lib}/update_test.ts (97%) rename {src => lib}/versions.ts (83%) rename {src => lib}/versions_test.ts (91%) delete mode 100644 src/types.ts diff --git a/cli.ts b/cli.ts index a0a25215..365ad6d3 100644 --- a/cli.ts +++ b/cli.ts @@ -4,8 +4,9 @@ import { parse as parseJsonc } from "./lib/std/jsonc.ts"; import { dirname, extname, join } from "./lib/std/path.ts"; import { colors, Command, List, Select } from "./lib/x/cliffy.ts"; import { URI } from "./lib/uri.ts"; -import { DependencyUpdate, FileUpdate } from "./mod.ts"; -import { commitAll } from "./git.ts"; +import { DependencyUpdate } from "./lib/update.ts"; +import { FileUpdate } from "./lib/file.ts"; +import { commitAll } from "./lib/git.ts"; const { gray, yellow, bold } = colors; diff --git a/git.ts b/git.ts index e1f21cf9..40cad92f 100644 --- a/git.ts +++ b/git.ts @@ -23,4 +23,4 @@ * @module */ -export * from "./src/git.ts"; +export * from "./lib/git.ts"; diff --git a/src/dependency.ts b/lib/dependency.ts similarity index 94% rename from src/dependency.ts rename to lib/dependency.ts index 3cec507c..54af8f87 100644 --- a/src/dependency.ts +++ b/lib/dependency.ts @@ -1,8 +1,7 @@ -import type { Maybe } from "../lib/types.ts"; -import { Mutex } from "../lib/x/async.ts"; -import type { Path, SemVerString } from "./types.ts"; +import { assertExists } from "./std/assert.ts"; +import { Mutex } from "./x/async.ts"; +import type { Maybe, Path, SemVerString } from "./types.ts"; import { parseSemVer } from "./semver.ts"; -import { assertExists } from "../lib/std/assert.ts"; export interface Dependency { name: string; diff --git a/src/dependency_test.ts b/lib/dependency_test.ts similarity index 90% rename from src/dependency_test.ts rename to lib/dependency_test.ts index dae9897f..56a1a1b8 100644 --- a/src/dependency_test.ts +++ b/lib/dependency_test.ts @@ -1,5 +1,5 @@ -import { describe, it } from "../lib/std/testing.ts"; -import { assertEquals } from "../lib/std/assert.ts"; +import { describe, it } from "./std/testing.ts"; +import { assertEquals } from "./std/assert.ts"; import { Dependency } from "./dependency.ts"; describe("parseProps()", () => { diff --git a/src/file.ts b/lib/file.ts similarity index 97% rename from src/file.ts rename to lib/file.ts index b4a8a6f6..c0ba3250 100644 --- a/src/file.ts +++ b/lib/file.ts @@ -1,5 +1,5 @@ import { DependencyUpdate } from "./update.ts"; -import { URI } from "../lib/uri.ts"; +import { URI } from "./uri.ts"; export interface FileUpdate { /** The specifier of the updated dependency (a remote module.) */ diff --git a/src/file_test.ts b/lib/file_test.ts similarity index 96% rename from src/file_test.ts rename to lib/file_test.ts index 6077e91f..f865f751 100644 --- a/src/file_test.ts +++ b/lib/file_test.ts @@ -5,15 +5,15 @@ import { it, type Stub, stub, -} from "../lib/std/testing.ts"; +} from "./std/testing.ts"; import { assertArrayIncludes, assertEquals, assertExists, -} from "../lib/std/assert.ts"; +} from "./std/assert.ts"; import { DependencyUpdate } from "./update.ts"; import { FileUpdate } from "./file.ts"; -import { URI } from "../lib/uri.ts"; +import { URI } from "./uri.ts"; describe("collect", () => { it("direct import", async () => { diff --git a/src/git.ts b/lib/git.ts similarity index 98% rename from src/git.ts rename to lib/git.ts index 55714b8c..8c8f7244 100644 --- a/src/git.ts +++ b/lib/git.ts @@ -1,7 +1,7 @@ import { DependencyUpdate } from "./update.ts"; import { FileUpdate } from "./file.ts"; import { createVersionProp, type VersionProp } from "./versions.ts"; -import { URI } from "../lib/uri.ts"; +import { URI } from "./uri.ts"; export interface CommitProps { /** The name of the module group */ diff --git a/src/git_test.ts b/lib/git_test.ts similarity index 96% rename from src/git_test.ts rename to lib/git_test.ts index 74cae21f..55903224 100644 --- a/src/git_test.ts +++ b/lib/git_test.ts @@ -1,5 +1,4 @@ // deno-lint-ignore-file no-explicit-any - import { afterAll, afterEach, @@ -9,9 +8,9 @@ import { it, type Stub, stub, -} from "../lib/std/testing.ts"; -import { assertArrayIncludes, assertEquals } from "../lib/std/assert.ts"; -import { URI } from "../lib/uri.ts"; +} from "./std/testing.ts"; +import { assertArrayIncludes, assertEquals } from "./std/assert.ts"; +import { URI } from "./uri.ts"; import { DependencyUpdate } from "./update.ts"; import { commitAll } from "./git.ts"; diff --git a/src/import_map.ts b/lib/import_map.ts similarity index 87% rename from src/import_map.ts rename to lib/import_map.ts index 54697f2a..70e30bd2 100644 --- a/src/import_map.ts +++ b/lib/import_map.ts @@ -1,9 +1,9 @@ -import { maxBy } from "../lib/std/collections.ts"; -import { parse as parseJsonc } from "../lib/std/jsonc.ts"; -import { type ImportMapJson, parseFromJson } from "../lib/x/import_map.ts"; -import { is } from "../lib/x/unknownutil.ts"; -import type { Maybe } from "../lib/types.ts"; -import { URI } from "../lib/uri.ts"; +import { maxBy } from "./std/collections.ts"; +import { parse as parseJsonc } from "./std/jsonc.ts"; +import { type ImportMapJson, parseFromJson } from "./x/import_map.ts"; +import { is } from "./x/unknownutil.ts"; +import type { Maybe } from "./types.ts"; +import { URI } from "./uri.ts"; import { URIScheme } from "./types.ts"; export type { ImportMapJson }; diff --git a/src/import_map_test.ts b/lib/import_map_test.ts similarity index 95% rename from src/import_map_test.ts rename to lib/import_map_test.ts index 57bbed7f..b711c555 100644 --- a/src/import_map_test.ts +++ b/lib/import_map_test.ts @@ -1,6 +1,6 @@ -import { beforeAll, describe, it } from "../lib/std/testing.ts"; -import { assertEquals, assertExists } from "../lib/std/assert.ts"; -import { URI } from "../lib/uri.ts"; +import { beforeAll, describe, it } from "./std/testing.ts"; +import { assertEquals, assertExists } from "./std/assert.ts"; +import { URI } from "./uri.ts"; import { ImportMap } from "./import_map.ts"; describe("readFromJson()", () => { diff --git a/src/loader.ts b/lib/loader.ts similarity index 94% rename from src/loader.ts rename to lib/loader.ts index 26968c46..27005e87 100644 --- a/src/loader.ts +++ b/lib/loader.ts @@ -1,7 +1,7 @@ import { type CreateGraphOptions, load as defaultLoad, -} from "../lib/x/deno_graph.ts"; +} from "./x/deno_graph.ts"; export const load: NonNullable = async ( specifier, diff --git a/src/semver.ts b/lib/semver.ts similarity index 87% rename from src/semver.ts rename to lib/semver.ts index 83a4b367..5d32f9cc 100644 --- a/src/semver.ts +++ b/lib/semver.ts @@ -1,5 +1,4 @@ -import type { Maybe } from "../lib/types.ts"; -import type { SemVerString } from "./types.ts"; +import type { Maybe, SemVerString } from "./types.ts"; // Ref: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string const SEMVER_REGEXP = diff --git a/src/semver_test.ts b/lib/semver_test.ts similarity index 76% rename from src/semver_test.ts rename to lib/semver_test.ts index c1e9b88b..609c8b27 100644 --- a/src/semver_test.ts +++ b/lib/semver_test.ts @@ -1,5 +1,5 @@ -import { describe, it } from "../lib/std/testing.ts"; -import { assertEquals } from "../lib/std/assert.ts"; +import { describe, it } from "./std/testing.ts"; +import { assertEquals } from "./std/assert.ts"; import { parseSemVer } from "./semver.ts"; describe("parseSemVer", () => { diff --git a/lib/types.ts b/lib/types.ts index d3d5f6c2..ef4dfbb8 100644 --- a/lib/types.ts +++ b/lib/types.ts @@ -1,2 +1,14 @@ export type Maybe = T | undefined; export type Brand = T & { __brand: B }; + +/** A string that represents a path segment (e.g. `src/lib.ts`.) */ +export type Path = Brand; + +/** A string that represents a semver (e.g. `v1.0.0`.) */ +export type SemVerString = Brand; + +const URI_SCHEMES = ["http", "https", "file", "npm", "node"] as const; +export type URIScheme = typeof URI_SCHEMES[number]; +export const URIScheme = { + values: URI_SCHEMES, +}; diff --git a/src/update.ts b/lib/update.ts similarity index 98% rename from src/update.ts rename to lib/update.ts index 7780f0a0..b26d774d 100644 --- a/src/update.ts +++ b/lib/update.ts @@ -2,8 +2,8 @@ import { createGraph, init as initDenoGraph, type ModuleJson, -} from "../lib/x/deno_graph.ts"; -import { RelativePath, URI } from "../lib/uri.ts"; +} from "./x/deno_graph.ts"; +import { RelativePath, URI } from "./uri.ts"; import type { SemVerString } from "./types.ts"; import { ImportMap, ImportMapJson } from "./import_map.ts"; import { Dependency } from "./dependency.ts"; diff --git a/src/update_test.ts b/lib/update_test.ts similarity index 97% rename from src/update_test.ts rename to lib/update_test.ts index 09cbf842..eaf42e18 100644 --- a/src/update_test.ts +++ b/lib/update_test.ts @@ -1,11 +1,11 @@ -import { beforeAll, describe, it } from "../lib/std/testing.ts"; +import { beforeAll, describe, it } from "./std/testing.ts"; import { assertEquals, assertExists, assertNotEquals, assertObjectMatch, -} from "../lib/std/assert.ts"; -import { URI } from "../lib/uri.ts"; +} from "./std/assert.ts"; +import { URI } from "./uri.ts"; import { _create, DependencyUpdate } from "./update.ts"; import { ImportMap } from "./import_map.ts"; diff --git a/src/versions.ts b/lib/versions.ts similarity index 83% rename from src/versions.ts rename to lib/versions.ts index 5d0a7429..cc31f0ab 100644 --- a/src/versions.ts +++ b/lib/versions.ts @@ -1,8 +1,8 @@ // Copyright 2023 Shun Ueda. All rights reserved. MIT license. -import type { Maybe } from "../lib/types.ts"; -import { distinct } from "../lib/std/collections.ts"; -import { DependencyUpdate } from "../mod.ts"; +import type { Maybe } from "./types.ts"; +import { distinct } from "./std/collections.ts"; +import { DependencyUpdate } from "./update.ts"; export type VersionProp = { from?: string; diff --git a/src/versions_test.ts b/lib/versions_test.ts similarity index 91% rename from src/versions_test.ts rename to lib/versions_test.ts index 5ffdd83a..03061cc3 100644 --- a/src/versions_test.ts +++ b/lib/versions_test.ts @@ -1,8 +1,8 @@ // deno-lint-ignore-file no-explicit-any -import { describe, it } from "../lib/std/testing.ts"; -import { assertEquals, assertThrows } from "../lib/std/assert.ts"; -import { createVersionProp } from "../src/versions.ts"; +import { describe, it } from "./std/testing.ts"; +import { assertEquals, assertThrows } from "./std/assert.ts"; +import { createVersionProp } from "./versions.ts"; describe("createVersionProps()", () => { it("single version", () => { diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index c68cb913..00000000 --- a/src/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Brand } from "../lib/types.ts"; - -/** A string that represents a path segment (e.g. `src/lib.ts`.) */ -export type Path = Brand; - -/** A string that represents a semver (e.g. `v1.0.0`.) */ -export type SemVerString = Brand; - -const URI_SCHEMES = ["http", "https", "file", "npm", "node"] as const; -export type URIScheme = typeof URI_SCHEMES[number]; -export const URIScheme = { - values: URI_SCHEMES, -}; From db5e71f1f8f391942f5303d36870d584bd729bdc Mon Sep 17 00:00:00 2001 From: hasundue Date: Sat, 21 Oct 2023 22:29:14 +0900 Subject: [PATCH 2/2] refactor(test): rename tests/ as test/fixtures --- deno.json | 2 +- lib/file_test.ts | 30 +++++++------- lib/git_test.ts | 22 ++++++----- lib/import_map_test.ts | 39 ++++++++++++------- lib/update_test.ts | 32 +++++++-------- {tests => test/fixtures}/direct-import/lib.ts | 0 {tests => test/fixtures}/direct-import/mod.ts | 0 .../fixtures}/import-map-no-resolve/deno.json | 0 .../fixtures}/import-map-no-resolve/mod.ts | 0 .../fixtures}/import-map-referred/deno.json | 0 .../import-map-referred/import_map.json | 0 .../fixtures}/import-map-referred/mod.ts | 0 {tests => test/fixtures}/import-map/deno.json | 0 {tests => test/fixtures}/import-map/lib.ts | 0 {tests => test/fixtures}/import-map/mod.ts | 0 15 files changed, 69 insertions(+), 56 deletions(-) rename {tests => test/fixtures}/direct-import/lib.ts (100%) rename {tests => test/fixtures}/direct-import/mod.ts (100%) rename {tests => test/fixtures}/import-map-no-resolve/deno.json (100%) rename {tests => test/fixtures}/import-map-no-resolve/mod.ts (100%) rename {tests => test/fixtures}/import-map-referred/deno.json (100%) rename {tests => test/fixtures}/import-map-referred/import_map.json (100%) rename {tests => test/fixtures}/import-map-referred/mod.ts (100%) rename {tests => test/fixtures}/import-map/deno.json (100%) rename {tests => test/fixtures}/import-map/lib.ts (100%) rename {tests => test/fixtures}/import-map/mod.ts (100%) 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