This commit is contained in:
Matthias Kretschmann 2019-04-14 19:09:08 +02:00
parent 6bdcda3141
commit 0666dba344
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 19 additions and 14 deletions

1
.gitignore vendored
View File

@ -11,5 +11,4 @@ yarn-debug.log*
yarn.lock
package-lock.json
plugins/gatsby-plugin-matomo
src/components/svg
coverage

View File

@ -1,10 +1,7 @@
sudo: required
dist: xenial
language: node_js
node_js: node
addons:
chrome: beta
cache:
directories:
- node_modules

View File

@ -4,21 +4,30 @@ import { render } from 'react-testing-library'
import LinkIcon from './LinkIcon'
describe('LinkIcon', () => {
const link = {
title: 'my project',
type: 'website'
}
it('renders correctly', () => {
const { container } = render(
<LinkIcon title={link.title} type={link.type} />
const { container, rerender } = render(
<LinkIcon title={'my project'} type={'website'} />
)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon type={'github'} />)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon type={'dribbble'} />)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon type={'info'} />)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon type={'download'} />)
expect(container.firstChild.nodeName).toBe('svg')
rerender(<LinkIcon type={'styleguide'} />)
expect(container.firstChild.nodeName).toBe('svg')
})
it('does not render with unknown type', () => {
const link = { type: 'whatever' }
const { container } = render(<LinkIcon type={link.type} />)
const { container } = render(<LinkIcon type={'whatever'} />)
expect(container.firstChild).not.toBeInTheDocument()
})
})