Skip to content

Commit

Permalink
test: more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
xidedix committed Jun 1, 2020
1 parent 735b5a0 commit 3bb20a9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
28 changes: 27 additions & 1 deletion tests/CIcon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@ import React from 'react'
import { renderToStaticMarkup as render } from 'react-dom/server'

import CIcon from 'src/'
import CIconRaw from 'src/'
import {logo, logo as cilLogo} from './logo'
React.icons = { logo, cilLogo }
import { cifAU } from './cif-AU';
React.icons = { logo, cilLogo, cifAU }

describe('CIcon', () => {

// polyfill
String.prototype.replaceAll = function(f,r){return this.split(f).join(r);}

it('renders svg with class="c-icon"', () => {
expect(render(<CIcon/>))
.toContain('class="c-icon')
Expand Down Expand Up @@ -43,4 +49,24 @@ describe('CIcon', () => {
expect(render(<CIcon use='xxx'/>))
.toContain('<use href="xxx"></use></svg>')
})
it('renders with title', () => {
expect(render(<CIcon name="cifAU" title="title"/>))
.toContain(cifAU[1])
})
it('warns on CIconRaw', () => {
expect(render(<CIconRaw/>))
.toContain('c-icon')
})
it('doesn`t warn on existing icon', () => {
expect(render(<CIcon name='cifAU'/>))
.toNotContain('undefined')
})
it('warns on non existing icon', () => {
expect(render(<CIcon name='none'/>))
.toContain('undefined')
})
it('converts toCamelCase', () => {
expect(render(<CIcon name='cif-AU'/>))
.toContain(cifAU[1])
})
})
1 change: 1 addition & 0 deletions tests/cif-AU.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3bb20a9

Please sign in to comment.