Files
homepage/src/utils/config/yaml.test.js
T
dependabot[bot]andshamoon a414f376b9 Chore(deps): Bump js-yaml from 4.3.1 to 5.3.0 (#7032)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
2026-08-21 07:18:27 -07:00

32 lines
1017 B
JavaScript

import { describe, expect, it } from "vitest";
import { loadYaml } from "./yaml";
describe("utils/config/yaml", () => {
it.each(["", " \n", "# comment only\n"])("loads an empty document from %j as undefined", (input) => {
expect(loadYaml(input)).toBeUndefined();
});
it("loads a populated document", () => {
expect(loadYaml("title: Homepage\n")).toEqual({ title: "Homepage" });
});
it("preserves v4 merge key behavior", () => {
expect(loadYaml("defaults: &defaults\n href: https://example.com\nservice:\n <<: *defaults\n")).toEqual({
defaults: { href: "https://example.com" },
service: { href: "https://example.com" },
});
});
it("preserves v4 timestamp behavior without enabling YAML 1.1 booleans", () => {
expect(loadYaml("date: 2026-08-21\nenabled: yes\n")).toEqual({
date: new Date("2026-08-21T00:00:00.000Z"),
enabled: "yes",
});
});
it("still rejects invalid YAML", () => {
expect(() => loadYaml("value: [\n")).toThrow();
});
});