summaryrefslogtreecommitdiff
path: root/src/serializers/to_object.test.ts
diff options
context:
space:
mode:
authorAsko Nõmm <asko@nmm.ee>2025-01-28 21:29:22 +0200
committerAsko Nõmm <asko@nmm.ee>2025-01-28 21:29:22 +0200
commit95692cf5540f1c0777ec08464ad5cc2a420406d6 (patch)
tree2746ecd1664ae1679d019d2d697aa6a092782e76 /src/serializers/to_object.test.ts
parent8a53d6c1870533c5020b00a509025293caa2637e (diff)
Improve docs, namings
Diffstat (limited to 'src/serializers/to_object.test.ts')
-rw-r--r--src/serializers/to_object.test.ts31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/serializers/to_object.test.ts b/src/serializers/to_object.test.ts
index 7059458..28cb78e 100644
--- a/src/serializers/to_object.test.ts
+++ b/src/serializers/to_object.test.ts
@@ -1,4 +1,4 @@
-import FlatMatter, {type FlatMatterFn} from "../flatmatter.ts";
+import FlatMatter, { type FlatMatterFn } from "../flatmatter.ts";
import ToObject from "./to_object.ts";
test("Single-level configuration", () => {
@@ -48,7 +48,7 @@ test("Simple function usage", () => {
}
}
- const fm = new FlatMatter('a: (to-upper "value")', [new ToUpper]);
+ const fm = new FlatMatter('a: (to-upper "value")', [new ToUpper()]);
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({
@@ -65,7 +65,7 @@ test("Piped function by reference usage", () => {
}
}
- const fm = new FlatMatter('a: "value" / to-upper', [new ToUpper]);
+ const fm = new FlatMatter('a: "value" / to-upper', [new ToUpper()]);
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({
@@ -82,7 +82,7 @@ test("Piped function by call usage", () => {
}
}
- const fm = new FlatMatter('a: "value" / (to-upper 123)', [new ToUpper]);
+ const fm = new FlatMatter('a: "value" / (to-upper 123)', [new ToUpper()]);
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({
@@ -95,16 +95,16 @@ test("Invalid value in pipe", () => {
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({});
-})
+});
test("Invalid value in pipe, 2", () => {
const fm = new FlatMatter('a: "value" / asd');
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({
- a: "value"
+ a: "value",
});
-})
+});
test("Only piped functions", () => {
class FirstFn implements FlatMatterFn {
@@ -123,11 +123,14 @@ test("Only piped functions", () => {
}
}
- const fm = new FlatMatter('a: (first-fn "value / here") / second-fn', [new FirstFn, new SecondFn]);
+ const fm = new FlatMatter('a: (first-fn "value / here") / second-fn', [
+ new FirstFn(),
+ new SecondFn(),
+ ]);
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({
- a: "VALUE / HERE-passed-by-second"
+ a: "VALUE / HERE-passed-by-second",
});
});
@@ -140,13 +143,13 @@ test("Function call without any args", () => {
}
}
- const fm = new FlatMatter('a: "value" / (to-upper)', [new ToUpper]);
+ const fm = new FlatMatter('a: "value" / (to-upper)', [new ToUpper()]);
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({
a: "VALUE",
});
-})
+});
test("Function call using multiple strings with spaces as arg", () => {
class ToUpper implements FlatMatterFn {
@@ -157,10 +160,12 @@ test("Function call using multiple strings with spaces as arg", () => {
}
}
- const fm = new FlatMatter('a: (to-upper "value goes here" "and here")', [new ToUpper]);
+ const fm = new FlatMatter('a: (to-upper "value goes here" "and here")', [
+ new ToUpper(),
+ ]);
const config = fm.serialize(new ToObject());
expect(config).toStrictEqual({
a: "VALUE GOES HERE",
});
-}) \ No newline at end of file
+});