std/front_matter/test_test.ts
Lino Le Van c46143f0ac
chore: update copyright year (#4046)
* chore: update copyright year

* fix

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-01-02 08:11:32 +11:00

61 lines
1.3 KiB
TypeScript

// 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("[ANY] try to test for unknown format", () => {
assertThrows(
() => test("foo", ["unknown"]),
TypeError,
"Unable to test for unknown front matter format",
);
});
// YAML //
Deno.test("[YAML] test valid input true", () => {
runTestValidInputTests("yaml", test);
});
Deno.test("[YAML] test invalid input false", () => {
runTestInvalidInputTests("yaml", test);
});
Deno.test({
name: "[YAML] text between horizontal rules should not be recognized",
async fn() {
const str = await Deno.readTextFile(
resolveTestDataPath("./horizontal_rules.md"),
);
assert(!test(str));
},
});
// JSON //
Deno.test("[JSON] test valid input true", () => {
runTestValidInputTests("json", test);
});
Deno.test("[JSON] test invalid input false", () => {
runTestInvalidInputTests("json", test);
});
// TOML //
Deno.test("[TOML] test valid input true", () => {
runTestValidInputTests("toml", test);
});
Deno.test("[TOML] test invalid input false", () => {
runTestInvalidInputTests("toml", test);
});