summaryrefslogtreecommitdiff
path: root/src/serializers
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2025-01-13 19:55:37 +0200
committerAsko Nõmm <asko@nmm.ee>2025-01-13 19:55:37 +0200
commit4e7dc3898e5cac5d5cf78687c25dcc0a342e7d9e (patch)
treed8a008ab0e0270940ff411c4d9b1e8b0c4a8a792 /src/serializers
parent71a6c1933d3e3f36fea8d982e4da896999da5194 (diff)
Add more test cases
Diffstat (limited to 'src/serializers')
-rw-r--r--src/serializers/to_object.test.ts34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/serializers/to_object.test.ts b/src/serializers/to_object.test.ts
index 9f13987..24fc54f 100644
--- a/src/serializers/to_object.test.ts
+++ b/src/serializers/to_object.test.ts
@@ -55,3 +55,37 @@ test("Simple function usage", () => {
a: "VALUE",
});
});
+
+test("Piped function by reference usage", () => {
+ class ToUpper implements FlatMatterFn {
+ name = "to-upper";
+
+ compute(input: string): unknown {
+ return input.toUpperCase();
+ }
+ }
+
+ const fm = new FlatMatter('a: "value" / to-upper', [new ToUpper()]);
+ const config = fm.serialize(new ToObject());
+
+ expect(config).toStrictEqual({
+ a: "VALUE",
+ });
+});
+
+test("Piped function by call usage", () => {
+ class ToUpper implements FlatMatterFn {
+ name = "to-upper";
+
+ compute(input: string, additional: number): unknown {
+ return `${input.toUpperCase()}-${additional}`;
+ }
+ }
+
+ const fm = new FlatMatter('a: "value" / (to-upper 123)', [new ToUpper()]);
+ const config = fm.serialize(new ToObject());
+
+ expect(config).toStrictEqual({
+ a: "VALUE-123",
+ });
+}); \ No newline at end of file