Skip to content

Commit

Permalink
test: update remaining testament tests to use bun:test like all other…
Browse files Browse the repository at this point in the history
… pkgs

- update tests & fixture handling
- update deps
- update `test:only` script alias in main package.json
  • Loading branch information
postspectacular committed Jul 3, 2024
1 parent 03499f4 commit e9d0979
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 218 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"examples": "yarn @example run build",
"pub": "yarn @thi.ng npm publish --tolerate-republish && yarn doc && bun tools/src/deploy-docs.ts",
"test": "yarn build:esbuild && yarn test:only",
"test:only": "bun test packages",
"test:only": "(cd packages && bun test)",
"tool:cleanup": "bun tools/src/cleanup.ts",
"tool:deps": "bun tools/src/adjacency.ts",
"tool:exports": "bun tools/src/generate-export-maps.ts && bun tools/src/check-exports.ts",
Expand Down
1 change: 0 additions & 1 deletion packages/bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
},
"devDependencies": {
"@microsoft/api-extractor": "^7.47.0",
"@thi.ng/testament": "^0.4.31",
"@types/node": "^20.14.6",
"esbuild": "^0.21.5",
"tools": "workspace:^",
Expand Down
3 changes: 1 addition & 2 deletions packages/tangle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
"pub": "yarn npm publish --access public",
"test": "testament test",
"test": "bun test",
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
},
"dependencies": {
Expand All @@ -50,7 +50,6 @@
},
"devDependencies": {
"@microsoft/api-extractor": "^7.47.0",
"@thi.ng/testament": "^0.4.31",
"esbuild": "^0.21.5",
"typedoc": "^0.25.13",
"typescript": "^5.5.2"
Expand Down
38 changes: 38 additions & 0 deletions packages/tangle/test/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { assert } from "@thi.ng/errors";
import { readText } from "@thi.ng/file-io";
import { expect, test } from "bun:test";
import { tangleFile, tangleString } from "../src/index.js";

test("md", () => {
const ctx = tangleFile(import.meta.dir + "/fixtures/main.md", {
opts: { comments: false },
});
const outs = Object.keys(ctx.outputs);
expect(outs.length).toBe(3);
for (let out of [
"out/ex01/src/bar.ts",
"out/ex01/src/index.ts",
"out/main.md",
]) {
out = `${import.meta.dir}/fixtures/${out}`;
assert(outs.includes(out), `missing output: ${out}`);
expect(ctx.outputs[out]).toBe(readText(out));
}
});

test("in-memory", () => {
const ctx = tangleString(
"a.org",
{
"a.org": readText(`${import.meta.dir}/fixtures/a.org`),
"b.org": readText(`${import.meta.dir}/fixtures/b.org`),
},
{
opts: { comments: false },
}
);
expect(ctx.outputs).toEqual({
"out/ex02/src/a.clj": "(def version 42)",
"out/a.org": readText(`${import.meta.dir}/fixtures/out/a.org`),
});
});
40 changes: 0 additions & 40 deletions packages/tangle/test/main.ts

This file was deleted.

3 changes: 1 addition & 2 deletions packages/transclude/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
"doc:readme": "bun ../../tools/src/module-stats.ts && bun ../../tools/src/readme.ts",
"pub": "yarn npm publish --access public",
"test": "testament test",
"test": "bun test",
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
},
"dependencies": {
Expand All @@ -45,7 +45,6 @@
},
"devDependencies": {
"@microsoft/api-extractor": "^7.47.0",
"@thi.ng/testament": "^0.4.31",
"esbuild": "^0.21.5",
"typedoc": "^0.25.13",
"typescript": "^5.5.2"
Expand Down
42 changes: 42 additions & 0 deletions packages/transclude/test/main.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { identity } from "@thi.ng/api";
import { readText } from "@thi.ng/file-io";
import { expect, test } from "bun:test";
import {
compactEmptyLines,
packageTemplates,
preincludeFile,
tabsToSpaces,
toc,
transcludeFile,
type Package,
} from "../src/index.js";

const DUMMY_PKG: Package = {
name: "@thi.ng/foobar",
version: "1.12.34",
description: "Look upon my works and despair",
author: "Asterix <[email protected]> (https://example.org)",
homepage: "https://thi.ng",
keywords: ["foo", "bar"],
contributors: ["Obelix", "Dogmatix (https://dogmatix.com)"],
license: "Apache-2.0",
};

test("transclude file", () => {
const src = transcludeFile<Package>(`${import.meta.dir}/fixtures/main.md`, {
user: DUMMY_PKG,
templates: {
...packageTemplates<Package>(identity, {
hdContributors: "##### Collaborators\n\n",
}),
},
pre: [preincludeFile],
post: [
toc({ title: "## Contents\n\n" }),
tabsToSpaces(),
compactEmptyLines,
],
}).src;
// writeFileSync(fixturePath("result.md"), src);
expect(src).toBe(readText(`${import.meta.dir}/fixtures/result.md`));
});
44 changes: 0 additions & 44 deletions packages/transclude/test/main.ts

This file was deleted.

Loading

0 comments on commit e9d0979

Please sign in to comment.