Skip to content

Commit

Permalink
chore: add test settings
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Oct 24, 2023
1 parent f442c8c commit c8f1923
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/core/settings.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});

0 comments on commit c8f1923

Please sign in to comment.