From ad34afc1236a0f6d09f312a5335aed9baeae51b6 Mon Sep 17 00:00:00 2001 From: eliabejr Date: Fri, 25 Jan 2019 17:44:54 -0300 Subject: [PATCH] feat(test-components): create test files for components --- __tests__/components/button.test.js | 28 +++++++++++ __tests__/components/clipboard.test.js | 25 ++++++++++ __tests__/components/confirm-dialog.test.js | 27 +++++++++++ __tests__/components/dropdown.test.js | 40 ++++++++++++++++ __tests__/components/input.test.js | 44 ++++++++++++++++++ __tests__/components/modal.test.js | 36 +++++++++++++++ __tests__/components/qrcode.test.js | 21 +++++++++ __tests__/components/sidebar.test.js | 16 +++++-- .../components/transactions-daily.test.js | 46 +++++++++++++++++++ __tests__/components/wallet-address.test.js | 29 ++++++++++++ 10 files changed, 307 insertions(+), 5 deletions(-) create mode 100644 __tests__/components/button.test.js create mode 100644 __tests__/components/clipboard.test.js create mode 100644 __tests__/components/confirm-dialog.test.js create mode 100644 __tests__/components/dropdown.test.js create mode 100644 __tests__/components/input.test.js create mode 100644 __tests__/components/modal.test.js create mode 100644 __tests__/components/qrcode.test.js create mode 100644 __tests__/components/transactions-daily.test.js create mode 100644 __tests__/components/wallet-address.test.js diff --git a/__tests__/components/button.test.js b/__tests__/components/button.test.js new file mode 100644 index 0000000..1eef549 --- /dev/null +++ b/__tests__/components/button.test.js @@ -0,0 +1,28 @@ +// @flow + +import React from 'react'; +import { render, cleanup } from 'react-testing-library'; +import { ThemeProvider } from 'styled-components'; +import 'jest-dom/extend-expect'; + +import { Button } from '../../app/components/button'; +import appTheme from '../../app/theme'; + +afterEach(cleanup); + +describe('} + > + {toggle =>
Confirm content
} + , + ); + + expect(container).toMatchSnapshot(); + }); + }); +}); diff --git a/__tests__/components/dropdown.test.js b/__tests__/components/dropdown.test.js new file mode 100644 index 0000000..a6e655a --- /dev/null +++ b/__tests__/components/dropdown.test.js @@ -0,0 +1,40 @@ +// @flow + +import React from 'react'; +import { render, cleanup } from 'react-testing-library'; +import { ThemeProvider } from 'styled-components'; +import 'jest-dom/extend-expect'; + +import { DropdownComponent } from '../../app/components/dropdown'; +import { Button } from '../../app/components/button'; +import appTheme from '../../app/theme'; + +afterEach(cleanup); + +describe('', () => { + describe('render()', () => { + test('should render dropdown correctly', () => { + const { container } = render( + +
+ ( +
+
, + ); + + expect(container).toMatchSnapshot(); + }); + }); +}); diff --git a/__tests__/components/input.test.js b/__tests__/components/input.test.js new file mode 100644 index 0000000..fb5ced4 --- /dev/null +++ b/__tests__/components/input.test.js @@ -0,0 +1,44 @@ +// @flow + +import React from 'react'; +import { render, cleanup } from 'react-testing-library'; +import { ThemeProvider } from 'styled-components'; +import 'jest-dom/extend-expect'; + +import { InputComponent } from '../../app/components/input'; +import appTheme from '../../app/theme'; + +afterEach(cleanup); + +describe('', () => { + describe('render()', () => { + test('should render text input correctly', () => { + const { container } = render( + + + + ); + + expect(container).toMatchSnapshot(); + }); + + test('should render textarea correctly', () => { + const { container } = render( + + + + ); + + expect(container).toMatchSnapshot(); + }); + }); +}); diff --git a/__tests__/components/modal.test.js b/__tests__/components/modal.test.js new file mode 100644 index 0000000..0f5bfd5 --- /dev/null +++ b/__tests__/components/modal.test.js @@ -0,0 +1,36 @@ +// @flow + +import React from 'react'; +import { render, cleanup } from 'react-testing-library'; +import 'jest-dom/extend-expect'; + +import { ModalComponent } from '../../app/components/modal'; + +afterEach(cleanup); + +describe('', () => { + describe('render()', () => { + test('should render modal correctly', () => { + const { container } = render( + ( + + )} + > + {toggleVisibility => ( +
+ Modal Content + +
+ )} +
, + ); + + expect(container).toMatchSnapshot(); + }); + }); +}); diff --git a/__tests__/components/qrcode.test.js b/__tests__/components/qrcode.test.js new file mode 100644 index 0000000..59adc3d --- /dev/null +++ b/__tests__/components/qrcode.test.js @@ -0,0 +1,21 @@ +// @flow + +import React from 'react'; +import { render, cleanup } from 'react-testing-library'; +import 'jest-dom/extend-expect'; + +import { QRCode } from '../../app/components/qrcode'; + +afterEach(cleanup); + +describe('', () => { + describe('render()', () => { + test('should render qrcode component correctly', () => { + const { container } = render( + , + ); + + expect(container).toMatchSnapshot(); + }); + }); +}); diff --git a/__tests__/components/sidebar.test.js b/__tests__/components/sidebar.test.js index 76975bd..602c093 100644 --- a/__tests__/components/sidebar.test.js +++ b/__tests__/components/sidebar.test.js @@ -1,20 +1,26 @@ // @flow import React from 'react'; -import { render } from 'react-testing-library'; +import { render, cleanup } from 'react-testing-library'; import { MemoryRouter } from 'react-router-dom'; +import { ThemeProvider } from 'styled-components'; import 'jest-dom/extend-expect'; import { SidebarComponent } from '../../app/components/sidebar'; +import appTheme from '../../app/theme'; -describe('', () => { +afterEach(cleanup); + +describe('', () => { describe('render()', () => { test('should render correctly', () => { // $FlowFixMe const { asFragment } = render( - - - , + + + + + , ); expect(asFragment()).toMatchSnapshot(); diff --git a/__tests__/components/transactions-daily.test.js b/__tests__/components/transactions-daily.test.js new file mode 100644 index 0000000..a999ded --- /dev/null +++ b/__tests__/components/transactions-daily.test.js @@ -0,0 +1,46 @@ +// @flow + +import React from 'react'; +import { render, cleanup } from 'react-testing-library'; +import { ThemeProvider } from 'styled-components'; +import 'jest-dom/extend-expect'; + +import { TransactionDailyComponent } from '../../app/components/transaction-daily'; +import appTheme from '../../app/theme'; + +afterEach(cleanup); + +describe('', () => { + describe('render()', () => { + test('should render user daily transactions', () => { + const { container } = render( + + + , + ); + + expect(container).toMatchSnapshot(); + }); + }); +}); diff --git a/__tests__/components/wallet-address.test.js b/__tests__/components/wallet-address.test.js new file mode 100644 index 0000000..d311243 --- /dev/null +++ b/__tests__/components/wallet-address.test.js @@ -0,0 +1,29 @@ +// @flow + +import React from 'react'; +import { render, cleanup } from 'react-testing-library'; +import { ThemeProvider } from 'styled-components'; +import 'jest-dom/extend-expect'; + +import { WalletAddress } from '../../app/components/wallet-address'; +import appTheme from '../../app/theme'; + +afterEach(cleanup); + +describe('', () => { + describe('render()', () => { + test('should render wallet address component correctly', () => { + const { container } = render( + +
+ +
+
, + ); + + expect(container).toMatchSnapshot(); + }); + }); +});