deno.land / std@0.224.0 / front_matter / test_test.ts
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import { assert, assertThrows } from "../assert/mod.ts";import { resolveTestDataPath, runTestInvalidInputTests, runTestValidInputTests,} from "./_test_utils.ts";import { test } from "./test.ts";
// GENERAL TESTS //
Deno.test("test() tests for unknown format", () => { assertThrows( () => test("foo", ["unknown"]), TypeError, "Unable to test for unknown front matter format", );});
// YAML //
Deno.test("test() handles valid yaml input", () => { runTestValidInputTests("yaml", test);});
Deno.test("test() handles invalid yaml input", () => { runTestInvalidInputTests("yaml", test);});
Deno.test({ name: "test() handles yaml text between horizontal rules", async fn() { const str = await Deno.readTextFile( resolveTestDataPath("./horizontal_rules.md"), );
assert(!test(str)); },});
// JSON //
Deno.test("test() handles valid json input", () => { runTestValidInputTests("json", test);});
Deno.test("test() handles invalid json input", () => { runTestInvalidInputTests("json", test);});
// TOML //
Deno.test("test() handles valid toml input", () => { runTestValidInputTests("toml", test);});
Deno.test("test() handles invalid toml input", () => { runTestInvalidInputTests("toml", test);});
Version Info