From 75a8e263fac611b42e11f21c852ce0aaba0b5845 Mon Sep 17 00:00:00 2001 From: Federico Babrauskas Date: Tue, 22 Oct 2019 14:18:57 -0300 Subject: [PATCH] Added tests for Clickable component --- src/components/Clickable/clickable.test.tsx | 33 +++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/components/Clickable/clickable.test.tsx diff --git a/src/components/Clickable/clickable.test.tsx b/src/components/Clickable/clickable.test.tsx new file mode 100644 index 0000000..3c880cc --- /dev/null +++ b/src/components/Clickable/clickable.test.tsx @@ -0,0 +1,33 @@ +import React from 'react' +import { render, cleanup } from '@testing-library/react' + +import Clickable, { ClickableProps } from './index' +import { AdaptProvider } from '../' +import 'jest-styled-components' + +afterEach(cleanup) + +describe('Clickable component', () => { + const renderComponent = (customProps?: ClickableProps) => + render( + + + + ) + + it('should render without crashing', () => { + const { container } = renderComponent() + expect(container.firstChild).toBeDefined() + }) + + it('should render with full styles', () => { + const { container } = renderComponent({ full: true }) + expect(container.firstChild).toHaveStyleRule('display', 'block') + expect(container.firstChild).toHaveStyleRule('width', '100%') + }) + + it('should render with disabled styles', () => { + const { container } = renderComponent({ disabled: true }) + expect(container.firstChild).toHaveStyleRule('cursor', 'not-allowed') + }) +})