summaryrefslogtreecommitdiff
path: root/src/serializers/to_object.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/serializers/to_object.test.ts')
-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