Skip to content

Commit

Permalink
Add Text test (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszantas authored and tarnas14 committed May 4, 2022
1 parent e98ed1e commit 4117b2a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions applications/launchpad_v2/src/components/Text/Text.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { render, screen } from '@testing-library/react'
import { ThemeProvider } from 'styled-components'

import Text from './'

import themes from '../../styles/themes'

describe('Text', () => {
it('should render Text component without crashing', () => {
const testText = 'The test text'
render(
<ThemeProvider theme={themes.light}>
<Text>{testText}</Text>
</ThemeProvider>,
)

const el = screen.getByText(testText)
expect(el).toBeInTheDocument()
})

it('should render DOM element of the given type', () => {
const testText = 'The test text'
const elType = 'span'
render(
<ThemeProvider theme={themes.light}>
<Text as={elType}>{testText}</Text>
</ThemeProvider>,
)

const el = screen.getByTestId('text-cmp')
expect(el.tagName.toLowerCase()).toBe(elType)
})
})

0 comments on commit 4117b2a

Please sign in to comment.