2020-05-07 08:03:30 +02:00
|
|
|
import React from 'react'
|
|
|
|
import { render } from '@testing-library/react'
|
|
|
|
import Button from '../../../src/components/atoms/Button'
|
|
|
|
|
|
|
|
describe('Button', () => {
|
|
|
|
it('primary renders correctly', () => {
|
2020-06-30 14:19:27 +02:00
|
|
|
const { container } = render(
|
|
|
|
<Button style="primary">I am a primary button</Button>
|
|
|
|
)
|
2020-05-07 08:03:30 +02:00
|
|
|
|
|
|
|
const button = container.querySelector('button')
|
|
|
|
expect(button).toBeInTheDocument()
|
|
|
|
expect(button).toHaveTextContent('primary')
|
|
|
|
expect(button && button.className).toMatch(/primary/)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('href renders correctly without crashing', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<Button href="https://hello.com">I am a href button</Button>
|
|
|
|
)
|
|
|
|
const button = container.querySelector('a')
|
|
|
|
expect(button).toBeInTheDocument()
|
|
|
|
expect(button).toHaveTextContent('href')
|
|
|
|
})
|
|
|
|
|
2020-06-30 14:19:27 +02:00
|
|
|
it('text renders correctly without crashing', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<Button style="text">I am a text button</Button>
|
|
|
|
)
|
2020-05-07 08:03:30 +02:00
|
|
|
|
|
|
|
const button = container.querySelector('button')
|
|
|
|
expect(button).toBeInTheDocument()
|
2020-06-30 14:19:27 +02:00
|
|
|
expect(button).toHaveTextContent('text')
|
|
|
|
expect(button && button.className).toMatch(/text/)
|
2020-05-07 08:03:30 +02:00
|
|
|
})
|
|
|
|
})
|