std/front_matter/json_test.ts
Yusuke Tanaka d13ef17a5d
docs(front-matter): improve docs for stabilization (#4789)
This commit improves docs of the front-matter module.

Specifically, the following things are done:

- Use `@example` where appropriate to render the examples more beautifully
- Split the big example attached to `createExtractor` function into smaller pieces so that each one has minimal yet meaningful example
- Add `@returns` to the `test` function
- Deduplicate `Format` type definition
- Add a brief description to `Format` type

Towards #3764

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-05-27 18:14:52 -07:00

27 lines
703 B
TypeScript

// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { test } from "./test.ts";
import { extract } from "./json.ts";
import {
runExtractJsonTests,
runExtractTypeErrorTests,
runTestInvalidInputTests,
runTestValidInputTests,
} from "./_test_utils.ts";
Deno.test("test() handles valid input", () => {
runTestValidInputTests("json", test);
});
Deno.test("test() handles invalid input", () => {
runTestInvalidInputTests("json", test);
});
Deno.test("json() extracts type error on invalid input", () => {
runExtractTypeErrorTests("json", extract);
});
Deno.test("json() parses json delineate by ---json", async () => {
await runExtractJsonTests(extract);
});