Skip to content

Commit

Permalink
Refactor test and snapshots to colocate next to source file
Browse files Browse the repository at this point in the history
  • Loading branch information
vnphanquang committed Dec 17, 2024
1 parent 869bd21 commit 6091caf
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 59 deletions.
7 changes: 4 additions & 3 deletions tests/errors.test.ts → scripts/builder.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { stub } from "@std/testing/mock";
import { assert, assertRejects } from "@std/assert";
import { sandbox } from "@lambdalisue/sandbox";
import { testPaletteSource } from "./utils.ts";
import base from "../scripts/targets/base/base.config.ts";
import { build } from "../scripts/builder.ts";

import { testPaletteSource } from "../tests/utils.ts";
import base from "./targets/base/base.config.ts";
import { build } from "./builder.ts";

Deno.test("should abort and clean up if Deno.remove throws unexpect error", async () => {
const errorMessage = "some Deno.remove error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ snapshot[`index.js 1`] = `
'
`;

snapshot[`index.d.ts 1`] = `
"declare namespace _default {
let red: {
50: string;
500: string;
};
let orange: {
100: string;
};
}
export default _default;
"
`;

snapshot[`index.cjs 1`] = `
'"use strict";
module.exports = {
Expand All @@ -27,17 +41,3 @@ module.exports = {
Object.defineProperty(exports, "__esModule", { value: true });
'
`;

snapshot[`index.d.ts 1`] = `
"declare namespace _default {
let red: {
50: string;
500: string;
};
let orange: {
100: string;
};
}
export default _default;
"
`;
6 changes: 6 additions & 0 deletions scripts/targets/base/base.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expectBuildToMatchSnapshot } from "../../../tests/utils.ts";
import base from "./base.config.ts";

Deno.test("build base target", async (t) => {
await expectBuildToMatchSnapshot(t, base);
});
File renamed without changes.
6 changes: 6 additions & 0 deletions scripts/targets/css/css.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expectBuildToMatchSnapshot } from "../../../tests/utils.ts";
import css from "./css.config.ts";

Deno.test("build css target", async (t) => {
await expectBuildToMatchSnapshot(t, css);
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@ snapshot[`index.css 1`] = `
"
`;

snapshot[`index.cjs 1`] = `
'"use strict";
module.exports = {
inherit: "inherit",
current: "currentColor",
transparent: "transparent",
black: "#000",
white: "#fff",
red: {
50: "oklch(0.988281 0.0046875 20 / <alpha-value>)",
500: "oklch(0.742188 0.151562 20 / <alpha-value>)",
},
orange: {
100: "oklch(0.966797 0.0171875 43.3333 / <alpha-value>)",
},
};
Object.defineProperty(exports, "__esModule", { value: true });
'
`;

snapshot[`index.d.ts 1`] = `
"declare namespace _default {
let inherit: string;
Expand Down Expand Up @@ -54,26 +77,3 @@ snapshot[`index.js 1`] = `
};
'
`;

snapshot[`index.cjs 1`] = `
'"use strict";
module.exports = {
inherit: "inherit",
current: "currentColor",
transparent: "transparent",
black: "#000",
white: "#fff",
red: {
50: "oklch(0.988281 0.0046875 20 / <alpha-value>)",
500: "oklch(0.742188 0.151562 20 / <alpha-value>)",
},
orange: {
100: "oklch(0.966797 0.0171875 43.3333 / <alpha-value>)",
},
};
Object.defineProperty(exports, "__esModule", { value: true });
'
`;
6 changes: 6 additions & 0 deletions scripts/targets/tailwind/tailwind.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { expectBuildToMatchSnapshot } from "../../../tests/utils.ts";
import tailwind from "./tailwind.config.ts";

Deno.test("build tailwind target", async (t) => {
await expectBuildToMatchSnapshot(t, tailwind);
});
7 changes: 0 additions & 7 deletions tests/base.test.ts

This file was deleted.

6 changes: 0 additions & 6 deletions tests/css.test.ts

This file was deleted.

6 changes: 0 additions & 6 deletions tests/tailwind.test.ts

This file was deleted.

0 comments on commit 6091caf

Please sign in to comment.