Skip to content

Commit

Permalink
Merge pull request #52 from fedebabrauskas/master
Browse files Browse the repository at this point in the history
Added tests for Clickable component
  • Loading branch information
matheusps committed Oct 23, 2019
2 parents c9e9b62 + 75a8e26 commit beecf4e
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/components/Clickable/clickable.test.tsx
Original file line number Diff line number Diff line change
@@ -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(
<AdaptProvider>
<Clickable {...customProps} />
</AdaptProvider>
)

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')
})
})

0 comments on commit beecf4e

Please sign in to comment.