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.
feat: specific field/input error reporting methods
- Loading branch information
1 parent
1995286
commit 3bfd22d
Showing
4 changed files
with
88 additions
and
33 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
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,23 @@ | ||
import { A, E, pipe } from "@std"; | ||
import { findFieldErrors } from "./findInputDefinitionSchema"; | ||
|
||
describe("findFieldErrors", () => { | ||
it("should return an empty array of detailed errors or unchanged fields if they are correct", () => { | ||
const fields = [ | ||
{ name: 'fieldName', description: 'field description', input: { type: 'text' } }, | ||
{ name: 'fieldName', input: { type: 'text' } }, | ||
{ name: 'fieldName', description: '', input: { type: '' } }, | ||
{}, | ||
]; | ||
const errors = pipe( | ||
findFieldErrors(fields), | ||
A.map(E.mapLeft((e) => e.toString())) | ||
) | ||
expect(errors).toHaveLength(4); | ||
expect(errors[0]).toEqual(E.right({ name: 'fieldName', description: 'field description', input: { type: 'text' } })); | ||
expect(errors[1]).toEqual(E.left('InvalidFieldError: description: Invalid type got undefined')); | ||
expect(errors[2]).toEqual(E.left('InvalidInputTypeError: "input.type" is invalid, got: ""')); | ||
expect(errors[3]).toEqual(E.left('InvalidFieldError: name: field name should be a string got undefined, description: Invalid type got undefined, input: Invalid type got undefined')); | ||
}); | ||
|
||
}); |
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
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