diff --git a/lib/file_test.ts b/lib/file_test.ts index 05c606ed..9f38264a 100644 --- a/lib/file_test.ts +++ b/lib/file_test.ts @@ -1,15 +1,16 @@ import { basename, dirname } from "./std/path.ts"; import { formatEOL, LF } from "./std/fs.ts"; +import { assert, assertInstanceOf } from "./std/assert.ts"; +import { fromFileUrl } from "./std/path.ts"; +import { createAssertSnapshot } from "./std/testing.ts"; +import { collect, CollectResult } from "./update.ts"; +import { associateByFile, type FileUpdate, writeFileUpdate } from "./file.ts"; import { FileSystemFake, + LatestVersionStub, ReadTextFileStub, WriteTextFileStub, } from "./testing.ts"; -import { assert, assertInstanceOf } from "./std/assert.ts"; -import { assertSnapshot } from "./testing.ts"; -import { collect, CollectResult } from "./update.ts"; -import { associateByFile, type FileUpdate, writeFileUpdate } from "./file.ts"; -import { LatestVersionStub } from "./testing.ts"; function toName(path: string) { const base = basename(path); @@ -18,6 +19,10 @@ function toName(path: string) { : base; } +const assertSnapshot = createAssertSnapshot({ + dir: fromFileUrl(new URL("../test/snapshots/", import.meta.url)), +}); + async function assertFileUpdateSnapshot( t: Deno.TestContext, results: FileUpdate[], diff --git a/lib/testing.ts b/lib/testing.ts index a45db1f3..22247f76 100644 --- a/lib/testing.ts +++ b/lib/testing.ts @@ -1,10 +1,6 @@ -import { createAssertSnapshot, spy, Stub, stub } from "./std/testing.ts"; +import { spy, Stub, stub } from "./std/testing.ts"; import { formatEOL, LF } from "./std/fs.ts"; -import { dirname, fromFileUrl } from "./std/path.ts"; - -export const assertSnapshot = createAssertSnapshot({ - dir: fromFileUrl(new URL("../test/snapshots/", import.meta.url)), -}); +import { dirname } from "./std/path.ts"; export const CommandStub = { create(pattern = "") { diff --git a/lib/update_test.ts b/lib/update_test.ts index 33419002..9b881d7e 100644 --- a/lib/update_test.ts +++ b/lib/update_test.ts @@ -1,11 +1,15 @@ import { dirname } from "./std/path.ts"; import { assertEquals, assertInstanceOf } from "./std/assert.ts"; import { filterKeys } from "./std/collections.ts"; -import { basename } from "./std/path.ts"; -import { assertSnapshot } from "./testing.ts"; +import { basename, fromFileUrl } from "./std/path.ts"; +import { createAssertSnapshot } from "./std/testing.ts"; import { LatestVersionStub } from "./testing.ts"; import { collect, DependencyUpdate } from "./update.ts"; +const assertSnapshot = createAssertSnapshot({ + dir: fromFileUrl(new URL("../test/snapshots/", import.meta.url)), +}); + function test( path: string, name = basename(path), diff --git a/test/integration/cli.ts b/test/integration/cli.ts index f63e415f..2cd5b6db 100644 --- a/test/integration/cli.ts +++ b/test/integration/cli.ts @@ -1,7 +1,7 @@ import { assertEquals } from "../../lib/std/assert.ts"; import { stripAnsiCode } from "../../lib/std/fmt.ts"; -import { join } from "../../lib/std/path.ts"; -import { assertSnapshot } from "../../lib/testing.ts"; +import { fromFileUrl, join } from "../../lib/std/path.ts"; +import { createAssertSnapshot } from "../../lib/std/testing.ts"; // basic commands molt("", { code: 2 }); @@ -115,3 +115,7 @@ function stringify(data: Uint8Array) { } return stripAnsiCode(text); } + +const assertSnapshot = createAssertSnapshot({ + dir: fromFileUrl(new URL("../snapshots/", import.meta.url)), +}); diff --git a/test/integration/registries.ts b/test/integration/registries.ts index 6478cf94..b80a91e9 100644 --- a/test/integration/registries.ts +++ b/test/integration/registries.ts @@ -1,4 +1,5 @@ -import { assertSnapshot } from "../../lib/testing.ts"; +import { fromFileUrl } from "../../lib/std/path.ts"; +import { createAssertSnapshot } from "../../lib/std/testing.ts"; import { parse, resolveLatestVersion } from "../../lib/dependency.ts"; type RegistryTestSpec = [ @@ -80,3 +81,7 @@ for (const spec of SPECS) { await assert(updated); }); } + +const assertSnapshot = createAssertSnapshot({ + dir: fromFileUrl(new URL("../snapshots/", import.meta.url)), +});