Skip to content

Commit

Permalink
chore: fix the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Jan 21, 2024
1 parent 6cdb104 commit fdc8b86
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions src/core/formDefinitionSchema.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { E, pipe } from "@std";
import { A, pipe } from "@std";
import { findFieldErrors } from "./findInputDefinitionSchema";
import { separated } from "fp-ts";

Expand All @@ -10,30 +10,24 @@ describe("findFieldErrors", () => {
{ name: "fieldName", description: "", input: { type: "" } },
{},
];
const errors = pipe(
const result = pipe(
// multi line prettier
findFieldErrors(fields),
separated.mapLeft((e) => e.toString()),
separated.left,
separated.mapLeft(A.map((e) => e.toString())),
);
expect(errors).toHaveLength(4);
expect(errors[0]).toEqual(
E.right({
name: "fieldName",
description: "field description",
input: { type: "text" },
}),
expect(result.left).toHaveLength(3);
expect(result.right).toHaveLength(1);
expect(result.right[0]).toEqual({
name: "fieldName",
description: "field description",
input: { type: "text" },
});
expect(result.left[0]).toEqual(
"InvalidFieldError: description: Invalid type got undefined",
);
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",
),
expect(result.left[1]).toEqual('InvalidInputTypeError: "input.type" is invalid, got: ""');
expect(result.left[2]).toEqual(
"InvalidFieldError: name: field name should be a string got undefined, description: Invalid type got undefined, input: Invalid type got undefined",
);
});
});

0 comments on commit fdc8b86

Please sign in to comment.