diff options
| author | Asko Nõmm <asko@nmm.ee> | 2025-01-13 19:55:37 +0200 |
|---|---|---|
| committer | Asko Nõmm <asko@nmm.ee> | 2025-01-13 19:55:37 +0200 |
| commit | 4e7dc3898e5cac5d5cf78687c25dcc0a342e7d9e (patch) | |
| tree | d8a008ab0e0270940ff411c4d9b1e8b0c4a8a792 /src | |
| parent | 71a6c1933d3e3f36fea8d982e4da896999da5194 (diff) | |
Add more test cases
Diffstat (limited to 'src')
| -rw-r--r-- | src/serializers/to_object.test.ts | 34 |
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 |
