generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f442c8c
commit c8f1923
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |