forked from thi-ng/umbrella
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: update remaining testament tests to use bun:test like all other…
… pkgs - update tests & fixture handling - update deps - update `test:only` script alias in main package.json
- Loading branch information
1 parent
03499f4
commit e9d0979
Showing
10 changed files
with
173 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`), | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`)); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.