Improve test coverage for select.tsx
This commit is contained in:
parent
add184d580
commit
30657f04d3
2 changed files with 57 additions and 3 deletions
|
@ -1,3 +1,13 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`select.tsx Tests \`current\`-value 1`] = `[Function]`;
|
||||
|
||||
exports[`select.tsx Tests \`current\`-value with testId 1`] = `[Function]`;
|
||||
|
||||
exports[`select.tsx Tests \`current\`-value without testId 1`] = `[Function]`;
|
||||
|
||||
exports[`select.tsx Tests Select rendering 1`] = `[Function]`;
|
||||
|
||||
exports[`select.tsx Tests rendering of multiple Select elements 1`] = `[Function]`;
|
||||
|
||||
exports[`select.tsx Tests select rendering 1`] = `[Function]`;
|
||||
|
|
|
@ -14,7 +14,7 @@ const items: Array<IItemProps> = [
|
|||
];
|
||||
|
||||
describe("select.tsx", () => {
|
||||
it("Tests select rendering", () => {
|
||||
it("Tests Select rendering", () => {
|
||||
const { asFragment } = render(
|
||||
<Select items={items} onChange={(item) => onChange(item)}></Select>,
|
||||
);
|
||||
|
@ -22,7 +22,26 @@ describe("select.tsx", () => {
|
|||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Tests select onChange", () => {
|
||||
it("Tests rendering of multiple Select elements", () => {
|
||||
const { asFragment } = render(
|
||||
<>
|
||||
<Select
|
||||
testId="1"
|
||||
items={items}
|
||||
onChange={(item) => onChange(item)}
|
||||
></Select>
|
||||
<Select
|
||||
testId="2"
|
||||
items={items}
|
||||
onChange={(item) => onChange(item)}
|
||||
></Select>
|
||||
</>,
|
||||
);
|
||||
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Tests Select onChange", () => {
|
||||
const select = render(
|
||||
<Select items={items} onChange={(item) => onChange(item)}></Select>,
|
||||
);
|
||||
|
@ -31,7 +50,7 @@ describe("select.tsx", () => {
|
|||
expect(onChange).toBeCalledWith(items[1]);
|
||||
});
|
||||
|
||||
it("Tests select onChange with undefined item", () => {
|
||||
it("Tests Select onChange with undefined item", () => {
|
||||
const select = render(
|
||||
<Select items={items} onChange={(item) => onChange(item)}></Select>,
|
||||
);
|
||||
|
@ -39,4 +58,29 @@ describe("select.tsx", () => {
|
|||
fireEvent.change(select.getByTestId("select"), { target: { value: 5 } });
|
||||
expect(onChange).toBeCalledWith(undefined);
|
||||
});
|
||||
|
||||
it("Tests `current`-value without testId", () => {
|
||||
const { asFragment } = render(
|
||||
<Select
|
||||
current={items[1].label}
|
||||
items={items}
|
||||
onChange={(item) => onChange(item)}
|
||||
></Select>,
|
||||
);
|
||||
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Tests `current`-value with testId", () => {
|
||||
const { asFragment } = render(
|
||||
<Select
|
||||
current={items[1].label}
|
||||
testId="1"
|
||||
items={items}
|
||||
onChange={(item) => onChange(item)}
|
||||
></Select>,
|
||||
);
|
||||
|
||||
expect(asFragment).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue