| 1 | import { assert, describe, it } from "@effect/vitest" |
| 2 | import * as Ini from "effect/encoding/Ini" |
| 3 | |
| 4 | describe("Ini", () => { |
| 5 | it("parses sections, arrays, and scalar values", () => { |
| 6 | assert.deepStrictEqual( |
| 7 | Ini.parse(` |
| 8 | enabled=true |
| 9 | missing=null |
| 10 | name=effect |
| 11 | tag[]=one |
| 12 | tag[]=two |
| 13 | |
| 14 | [database.pool] |
| 15 | size=10 |
| 16 | `), |
| 17 | { |
| 18 | enabled: true, |
| 19 | missing: null, |
| 20 | name: "effect", |
| 21 | tag: ["one", "two"], |
| 22 | database: { |
| 23 | pool: { |
| 24 | size: "10" |
| 25 | } |
| 26 | } |
| 27 | } |
| 28 | ) |
| 29 | }) |
| 30 | |
| 31 | it("supports quoted values, comments, and escaped section dots", () => { |
| 32 | assert.deepStrictEqual( |
| 33 | Ini.parse(` |
| 34 | plain=value ; comment |
| 35 | quoted="value # retained" |
| 36 | [a\\.b] |
| 37 | key=yes |
| 38 | `), |
| 39 | { |
| 40 | plain: "value", |
| 41 | quoted: "value # retained", |
| 42 | "a.b": { |
| 43 | key: "yes" |
| 44 | } |
| 45 | } |
| 46 | ) |
| 47 | }) |
| 48 | }) |