Skip to content

Commit

Permalink
chore: make tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Jan 2, 2024
1 parent dcefe7c commit b8d0826
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
3 changes: 2 additions & 1 deletion src/core/formDataFromDefaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("formDataFromFormOptions", () => {
input: {
type: "multiselect",
source: "fixed",
allowUnknownValues: false,
multi_select_options: ["reading", "swimming", "running"],
},
},
Expand Down Expand Up @@ -61,7 +62,7 @@ describe("formDataFromFormOptions", () => {
expect(result).toEqual(expectedFormData);
});

it("should ensure toggles always have avalue even when no values are provided", () => {
it("should ensure toggles always have a value even when no values are provided", () => {
const values = {};

const expectedFormData = { isEmployed: false };
Expand Down
45 changes: 14 additions & 31 deletions src/core/formDefinition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,25 @@ import { parse } from "valibot";

describe("isDataViewSource", () => {
it("should return true for valid inputDataviewSource objects", () => {
expect(
isDataViewSource({ type: "dataview", query: "some query" }),
).toBe(true);
expect(isDataViewSource({ type: "dataview", query: "some query" })).toBe(true);
});

it("should return false for invalid inputDataviewSource objects", () => {
expect(isDataViewSource({ type: "dataview" })).toBe(false);
expect(isDataViewSource({ type: "dataview", query: 123 })).toBe(false);
expect(isDataViewSource({ type: "select", query: "some query" })).toBe(
false,
);
expect(isDataViewSource({ type: "select", query: "some query" })).toBe(false);
});
});

describe("isInputNoteFromFolder", () => {
it("should return true for valid inputNoteFromFolder objects", () => {
expect(
isInputNoteFromFolder({ type: "note", folder: "some folder" }),
).toBe(true);
expect(isInputNoteFromFolder({ type: "note", folder: "some folder" })).toBe(true);
});

it("should return false for invalid inputNoteFromFolder objects", () => {
expect(isInputNoteFromFolder({ type: "note" })).toBe(false);
expect(isInputNoteFromFolder({ type: "note", folder: 123 })).toBe(
false,
);
expect(
isInputNoteFromFolder({ type: "select", folder: "some folder" }),
).toBe(false);
expect(isInputNoteFromFolder({ type: "note", folder: 123 })).toBe(false);
expect(isInputNoteFromFolder({ type: "select", folder: "some folder" })).toBe(false);
});
});

Expand All @@ -54,9 +44,7 @@ describe("isInputSelectFixed", () => {
});

it("should return false for invalid inputSelectFixed objects", () => {
expect(isInputSelectFixed({ type: "select", source: "fixed" })).toBe(
false,
);
expect(isInputSelectFixed({ type: "select", source: "fixed" })).toBe(false);
expect(
isInputSelectFixed({
type: "select",
Expand All @@ -81,9 +69,7 @@ describe("isInputSlider", () => {

it("should return false for invalid inputSlider objects", () => {
expect(isInputSlider({ type: "slider" })).toBe(false);
expect(isInputSlider({ type: "slider", min: "0", max: 10 })).toBe(
false,
);
expect(isInputSlider({ type: "slider", min: "0", max: 10 })).toBe(false);
expect(isInputSlider({ type: "select", min: 0, max: 10 })).toBe(false);
});
});
Expand All @@ -100,15 +86,9 @@ describe("isSelectFromNotes", () => {
});

it("should return false for invalid selectFromNotes objects", () => {
expect(isSelectFromNotes({ type: "select", source: "notes" })).toBe(
false,
);
expect(
isSelectFromNotes({ type: "select", source: "notes", folder: 123 }),
).toBe(false);
expect(isSelectFromNotes({ type: "note", folder: "some folder" })).toBe(
false,
);
expect(isSelectFromNotes({ type: "select", source: "notes" })).toBe(false);
expect(isSelectFromNotes({ type: "select", source: "notes", folder: 123 })).toBe(false);
expect(isSelectFromNotes({ type: "note", folder: "some folder" })).toBe(false);
});
});
describe("MultiSelectFixedSchema", () => {
Expand All @@ -118,7 +98,10 @@ describe("MultiSelectFixedSchema", () => {
source: "fixed",
multi_select_options: ["Option 1", "Option 2", "Option 3"],
};
expect(parse(MultiselectSchema, validSchema)).toEqual(validSchema);
expect(parse(MultiselectSchema, validSchema)).toEqual({
allowUnknownValues: false,
...validSchema,
});
});

it("should not validate an invalid multiselect fixed schema with missing properties", () => {
Expand Down

0 comments on commit b8d0826

Please sign in to comment.