Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(testing): call createAssertSnapshot in each test module #157

Merged
merged 2 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 0 additions & 117 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions lib/file_test.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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[],
Expand Down
8 changes: 2 additions & 6 deletions lib/testing.ts
Original file line number Diff line number Diff line change
@@ -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 = "") {
Expand Down
8 changes: 6 additions & 2 deletions lib/update_test.ts
Original file line number Diff line number Diff line change
@@ -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),
Expand Down
8 changes: 6 additions & 2 deletions test/integration/cli.ts
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down Expand Up @@ -115,3 +115,7 @@ function stringify(data: Uint8Array) {
}
return stripAnsiCode(text);
}

const assertSnapshot = createAssertSnapshot({
dir: fromFileUrl(new URL("../snapshots/", import.meta.url)),
});
7 changes: 6 additions & 1 deletion test/integration/registries.ts
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down Expand Up @@ -80,3 +81,7 @@ for (const spec of SPECS) {
await assert(updated);
});
}

const assertSnapshot = createAssertSnapshot({
dir: fromFileUrl(new URL("../snapshots/", import.meta.url)),
});