Skip to content

Commit

Permalink
test(multi-select): isOptional test added
Browse files Browse the repository at this point in the history
  • Loading branch information
DobroTora committed Dec 8, 2023
1 parent 629ca6a commit af1c281
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, {
useCallback,
useMemo,
} from "react";
import invariant from "invariant";
import { Side } from "@floating-ui/dom";

import { filterOutStyledSystemSpacingProps } from "../../../style/utils";
Expand Down
27 changes: 13 additions & 14 deletions src/components/select/multi-select/multi-select.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useRef, useState } from "react";
import { act } from "react-dom/test-utils";
import { mount, ReactWrapper } from "enzyme";
import { mount, shallow, ReactWrapper } from "enzyme";

import {
assertStyleMatch,
Expand Down Expand Up @@ -1118,20 +1118,19 @@ describe("MultiSelect", () => {
});

describe("isOptional", () => {
let wrapper: ReactWrapper;

beforeAll(() => {
wrapper = renderSelect({ label: "optional", isOptional: true });
});

it("the isOptional prop is passed to the input", () => {
const input = wrapper.find("input");
expect(input.prop("optional")).toBe(true);
});
it("the isOptional prop is passed to the inputs", () => {
const propWrapper = shallow(
<MultiSelect name="testSelect" id="testSelect" isOptional>
<Option value="opt1" text="red" borderColor="red" fill />
<Option value="opt2" text="green" borderColor="green" />
<Option value="opt3" text="blue" />
</MultiSelect>
);

it("the isOptional prop is passed to the label", () => {
const label = wrapper.find(Label);
expect(label.prop("optional")).toBe(true);
const inputs = propWrapper.find("input");
inputs.forEach((input) => {
expect(input.prop("isOptional")).toBe(true);
});
});
});

Expand Down

0 comments on commit af1c281

Please sign in to comment.