Refactor to move parseConfiguration function into a separate file, add stronger typing, add first test case.

This commit is contained in:
David Anson 2025-02-28 20:25:44 -08:00
parent c4d15e0d2a
commit 1f237e6c54
4 changed files with 72 additions and 38 deletions

View file

@ -0,0 +1,24 @@
// @ts-check
import test from "ava";
import parseConfiguration from "../lib/parse-configuration.mjs";
const testObject = {
"string": "text",
"number": 10,
"object": {
"property": "value"
},
"array": [ 1, 2, 3 ]
};
const successfulTestObjectResult = {
"config": testObject,
"message": ""
};
const testObjectJsonString = JSON.stringify(testObject);
test("json object, default parsers", (t) => {
t.plan(1);
const actual = parseConfiguration("name", testObjectJsonString);
t.deepEqual(actual, successfulTestObjectResult);
});