From 30657f04d3422a7d08ff71942345146fd75d7205 Mon Sep 17 00:00:00 2001 From: Bastian Meissner Date: Fri, 26 Nov 2021 18:15:39 +0100 Subject: [PATCH] Improve test coverage for select.tsx --- .../__snapshots__/select.spec.tsx.snap | 10 ++++ src/test/components/select.spec.tsx | 50 +++++++++++++++++-- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/test/components/__snapshots__/select.spec.tsx.snap b/src/test/components/__snapshots__/select.spec.tsx.snap index 94ce9c6..1e270e2 100644 --- a/src/test/components/__snapshots__/select.spec.tsx.snap +++ b/src/test/components/__snapshots__/select.spec.tsx.snap @@ -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]`; diff --git a/src/test/components/select.spec.tsx b/src/test/components/select.spec.tsx index 554abf5..aaefca9 100644 --- a/src/test/components/select.spec.tsx +++ b/src/test/components/select.spec.tsx @@ -14,7 +14,7 @@ const items: Array = [ ]; describe("select.tsx", () => { - it("Tests select rendering", () => { + it("Tests Select rendering", () => { const { asFragment } = render( , ); @@ -22,7 +22,26 @@ describe("select.tsx", () => { expect(asFragment).toMatchSnapshot(); }); - it("Tests select onChange", () => { + it("Tests rendering of multiple Select elements", () => { + const { asFragment } = render( + <> + + + , + ); + + expect(asFragment).toMatchSnapshot(); + }); + + it("Tests Select onChange", () => { const select = render( , ); @@ -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( , ); @@ -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( + , + ); + + expect(asFragment).toMatchSnapshot(); + }); + + it("Tests `current`-value with testId", () => { + const { asFragment } = render( + , + ); + + expect(asFragment).toMatchSnapshot(); + }); });