Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/front_matter/test_test.ts

Deno standard library
Go to Latest
File
// 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);});