From c8f19236ed8729c4ef653dd8096739ae73bb489f Mon Sep 17 00:00:00 2001 From: Danielo Rodriguez Date: Tue, 24 Oct 2023 17:55:41 +0200 Subject: [PATCH] chore: add test settings --- src/core/settings.test.ts | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/core/settings.test.ts diff --git a/src/core/settings.test.ts b/src/core/settings.test.ts new file mode 100644 index 00000000..aa820199 --- /dev/null +++ b/src/core/settings.test.ts @@ -0,0 +1,35 @@ +import { parseSettings } from "./settings"; +import * as E from "fp-ts/Either"; + +describe("parseSettings", () => { + it("should return the default settings when given null", () => { + const result = parseSettings(null); + expect(E.isRight(result)).toBe(true); + if (E.isRight(result)) { + expect(result.right).toEqual({ + editorPosition: "right", + formDefinitions: [], + }); + } + }); + + it("should return the parsed settings when given valid input", () => { + const input = { + editorPosition: "left", + formDefinitions: [], + }; + const result = parseSettings(input); + expect(E.isRight(result)).toBe(true); + if (E.isRight(result)) expect(result.right).toEqual(input); + }); + + it("should return a validation error when given invalid input", () => { + const input = { + editorPosition: "lift", + formDefinitions: [], + }; + const result = parseSettings(input); + expect(E.isLeft(result)).toBe(true); + if (E.isLeft(result)) expect(result.left).toBeDefined(); + }); +});