import {deepStrictEqual} from "assert"; import {parse} from "../index.js"; const SIMPLE_KV_VALUES = `text: "text" integer: 123 float: 123.456 ` const OBJECT = `object { text: "text" integer: 123 float: 123.456 } ` const OBJECTS = `object1 { text: "text" integer: 123 float: 123.456 } object2 { text: "text" integer: 123 float: 123.456 } ` const OBJECT_AND_SIMPLE_VALUES = `text: "text" integer: 123 float: 123.456 object1 { text: "text" integer: 123 float: 123.456 } object2 { text: "text" integer: 123 float: 123.456 } ` const MULTIPLE_OBJECT_WITH_SAME_KEY = `value { k: 1 } value { k: 2 } value { v: 1 y: "x" } ` describe("#parse()", () => { it("should parse simple KV values", () => { deepStrictEqual({ "text": "text", "integer": 123, "float": 123.456, }, parse(SIMPLE_KV_VALUES)) }) it("should parse a single object", () => { deepStrictEqual({ "object": { "text": "text", "integer": 123, "float": 123.456, }, }, parse(OBJECT)) }) it("should parse multiple objects", () => { deepStrictEqual({ "object1": { "text": "text", "integer": 123, "float": 123.456, }, "object2": { "text": "text", "integer": 123, "float": 123.456, }, }, parse(OBJECTS)) }) it("should parse objects and simple values", () => { deepStrictEqual({ "text": "text", "integer": 123, "float": 123.456, "object1": { "text": "text", "integer": 123, "float": 123.456, }, "object2": { "text": "text", "integer": 123, "float": 123.456, }, }, parse(OBJECT_AND_SIMPLE_VALUES)) }) it("should parse objects with the same key", () => { deepStrictEqual({ "value": [ {"k": 1}, {"k": 2}, {"v": 1, "y": "x"}, ] }, parse(MULTIPLE_OBJECT_WITH_SAME_KEY)) }) })