From d04b9d818c2c1bb0b8a4b2d74f9895a2a762c57d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bel=C3=A9n=20Curcio?= Date: Wed, 12 Sep 2018 09:20:50 -0300 Subject: [PATCH] Test added --- .../client/ui/components/Tabs/Tab.spec.tsx | 9 +++++ .../client/ui/components/Tabs/TabBar.spec.tsx | 18 +++++++++ .../ui/components/Tabs/TabContent.spec.tsx | 31 +++++++++++++++ .../client/ui/components/Tabs/TabPane.css | 0 .../ui/components/Tabs/TabPane.spec.tsx | 9 +++++ .../Tabs/__snapshots__/Tab.spec.tsx.snap | 13 +++++++ .../Tabs/__snapshots__/TabBar.spec.tsx.snap | 39 +++++++++++++++++++ .../__snapshots__/TabContent.spec.tsx.snap | 11 ++++++ .../Tabs/__snapshots__/TabPane.spec.tsx.snap | 11 ++++++ 9 files changed, 141 insertions(+) create mode 100644 src/core/client/ui/components/Tabs/Tab.spec.tsx create mode 100644 src/core/client/ui/components/Tabs/TabContent.spec.tsx delete mode 100644 src/core/client/ui/components/Tabs/TabPane.css create mode 100644 src/core/client/ui/components/Tabs/TabPane.spec.tsx create mode 100644 src/core/client/ui/components/Tabs/__snapshots__/Tab.spec.tsx.snap create mode 100644 src/core/client/ui/components/Tabs/__snapshots__/TabBar.spec.tsx.snap create mode 100644 src/core/client/ui/components/Tabs/__snapshots__/TabContent.spec.tsx.snap create mode 100644 src/core/client/ui/components/Tabs/__snapshots__/TabPane.spec.tsx.snap diff --git a/src/core/client/ui/components/Tabs/Tab.spec.tsx b/src/core/client/ui/components/Tabs/Tab.spec.tsx new file mode 100644 index 000000000..3af6a904a --- /dev/null +++ b/src/core/client/ui/components/Tabs/Tab.spec.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import TestRenderer from "react-test-renderer"; + +import Tab from "./Tab"; + +it("renders correctly", () => { + const renderer = TestRenderer.create(Three); + expect(renderer.toJSON()).toMatchSnapshot(); +}); diff --git a/src/core/client/ui/components/Tabs/TabBar.spec.tsx b/src/core/client/ui/components/Tabs/TabBar.spec.tsx index ef12f60d3..ffe91d4fd 100644 --- a/src/core/client/ui/components/Tabs/TabBar.spec.tsx +++ b/src/core/client/ui/components/Tabs/TabBar.spec.tsx @@ -14,3 +14,21 @@ it("renders correctly", () => { ); expect(renderer.toJSON()).toMatchSnapshot(); }); + +it("sets initial tab as active", () => { + const renderer = TestRenderer.create( + + One + Two + Three + + ); + + const testInstance = renderer.root; + expect(testInstance.findByType(TabBar).props.activeTab).toBe("one"); + const tabs = testInstance.findAllByType(Tab); + expect(tabs.length).toBe(3); + expect(tabs[0].props.active).toBe(true); + expect(tabs[1].props.active).toBe(false); + expect(tabs[2].props.active).toBe(false); +}); diff --git a/src/core/client/ui/components/Tabs/TabContent.spec.tsx b/src/core/client/ui/components/Tabs/TabContent.spec.tsx new file mode 100644 index 000000000..f411b53f5 --- /dev/null +++ b/src/core/client/ui/components/Tabs/TabContent.spec.tsx @@ -0,0 +1,31 @@ +import React from "react"; +import TestRenderer from "react-test-renderer"; + +import TabContent from "./TabContent"; +import TabPane from "./TabPane"; + +it("renders correctly", () => { + const renderer = TestRenderer.create( + + Hola One + Hola Two + Hola Three + + ); + expect(renderer.toJSON()).toMatchSnapshot(); +}); + +it("sets initial tab as active, renders only one", () => { + const renderer = TestRenderer.create( + + Hola One + Hola Two + Hola Three + + ); + + const testInstance = renderer.root; + expect(testInstance.findByType(TabContent).props.activeTab).toBe("one"); + const panes = testInstance.findAllByType(TabPane); + expect(panes.length).toBe(1); +}); diff --git a/src/core/client/ui/components/Tabs/TabPane.css b/src/core/client/ui/components/Tabs/TabPane.css deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/core/client/ui/components/Tabs/TabPane.spec.tsx b/src/core/client/ui/components/Tabs/TabPane.spec.tsx new file mode 100644 index 000000000..595e054de --- /dev/null +++ b/src/core/client/ui/components/Tabs/TabPane.spec.tsx @@ -0,0 +1,9 @@ +import React from "react"; +import TestRenderer from "react-test-renderer"; + +import TabPane from "./TabPane"; + +it("renders correctly", () => { + const renderer = TestRenderer.create(Three); + expect(renderer.toJSON()).toMatchSnapshot(); +}); diff --git a/src/core/client/ui/components/Tabs/__snapshots__/Tab.spec.tsx.snap b/src/core/client/ui/components/Tabs/__snapshots__/Tab.spec.tsx.snap new file mode 100644 index 000000000..cd06a91e8 --- /dev/null +++ b/src/core/client/ui/components/Tabs/__snapshots__/Tab.spec.tsx.snap @@ -0,0 +1,13 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` + +`; diff --git a/src/core/client/ui/components/Tabs/__snapshots__/TabBar.spec.tsx.snap b/src/core/client/ui/components/Tabs/__snapshots__/TabBar.spec.tsx.snap new file mode 100644 index 000000000..1a4ec45de --- /dev/null +++ b/src/core/client/ui/components/Tabs/__snapshots__/TabBar.spec.tsx.snap @@ -0,0 +1,39 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` + +`; diff --git a/src/core/client/ui/components/Tabs/__snapshots__/TabContent.spec.tsx.snap b/src/core/client/ui/components/Tabs/__snapshots__/TabContent.spec.tsx.snap new file mode 100644 index 000000000..0fb2810e0 --- /dev/null +++ b/src/core/client/ui/components/Tabs/__snapshots__/TabContent.spec.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` +
+ Hola One +
+`; diff --git a/src/core/client/ui/components/Tabs/__snapshots__/TabPane.spec.tsx.snap b/src/core/client/ui/components/Tabs/__snapshots__/TabPane.spec.tsx.snap new file mode 100644 index 000000000..97032314c --- /dev/null +++ b/src/core/client/ui/components/Tabs/__snapshots__/TabPane.spec.tsx.snap @@ -0,0 +1,11 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`renders correctly 1`] = ` +
+ Three +
+`;