diff options
Diffstat (limited to 'src/serializers/to_object.test.ts')
| -rw-r--r-- | src/serializers/to_object.test.ts | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/serializers/to_object.test.ts b/src/serializers/to_object.test.ts index 98b165a..9f13987 100644 --- a/src/serializers/to_object.test.ts +++ b/src/serializers/to_object.test.ts @@ -1,13 +1,12 @@ -import { assertEquals } from "jsr:@std/assert"; -import FlatMatter from "../flatmatter.ts"; +import FlatMatter, {type FlatMatterFn} from "../flatmatter.ts"; import ToObject from "./to_object.ts"; -Deno.test("Single-level configuration", () => { +test("Single-level configuration", () => { const fm = new FlatMatter( - 'a: true\nb: false\nc: 1\nd: 12.5\nf: "some string"', + 'a: true\nb: false\nc: 1\nd: 12.5\nf: "some string"' ); - assertEquals(fm.serialize(new ToObject()), { + expect(fm.serialize(new ToObject())).toStrictEqual({ a: true, b: false, c: 1, @@ -16,12 +15,12 @@ Deno.test("Single-level configuration", () => { }); }); -Deno.test("Two-level configuration", () => { +test("Two-level configuration", () => { const fm = new FlatMatter( - 'a.a: true\nb.b: false\nc.c: 1\nd.d: 12.5\nf.f: "some string"', + 'a.a: true\nb.b: false\nc.c: 1\nd.d: 12.5\nf.f: "some string"' ); - assertEquals(fm.serialize(new ToObject()), { + expect(fm.serialize(new ToObject())).toStrictEqual({ a: { a: true, }, @@ -39,3 +38,20 @@ Deno.test("Two-level configuration", () => { }, }); }); + +test("Simple function usage", () => { + class ToUpper implements FlatMatterFn { + name = "to-upper"; + + compute(input: string): unknown { + return input.toUpperCase(); + } + } + + const fm = new FlatMatter('a: (to-upper "value")', [new ToUpper()]); + const config = fm.serialize(new ToObject()); + + expect(config).toStrictEqual({ + a: "VALUE", + }); +}); |
