Skip to content

Commit 3bb20a9

Browse files
committed
test: more coverage
1 parent 735b5a0 commit 3bb20a9

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Diff for: tests/CIcon.test.js

+27-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ import React from 'react'
33
import { renderToStaticMarkup as render } from 'react-dom/server'
44

55
import CIcon from 'src/'
6+
import CIconRaw from 'src/'
67
import {logo, logo as cilLogo} from './logo'
7-
React.icons = { logo, cilLogo }
8+
import { cifAU } from './cif-AU';
9+
React.icons = { logo, cilLogo, cifAU }
810

911
describe('CIcon', () => {
12+
13+
// polyfill
14+
String.prototype.replaceAll = function(f,r){return this.split(f).join(r);}
15+
1016
it('renders svg with class="c-icon"', () => {
1117
expect(render(<CIcon/>))
1218
.toContain('class="c-icon')
@@ -43,4 +49,24 @@ describe('CIcon', () => {
4349
expect(render(<CIcon use='xxx'/>))
4450
.toContain('<use href="xxx"></use></svg>')
4551
})
52+
it('renders with title', () => {
53+
expect(render(<CIcon name="cifAU" title="title"/>))
54+
.toContain(cifAU[1])
55+
})
56+
it('warns on CIconRaw', () => {
57+
expect(render(<CIconRaw/>))
58+
.toContain('c-icon')
59+
})
60+
it('doesn`t warn on existing icon', () => {
61+
expect(render(<CIcon name='cifAU'/>))
62+
.toNotContain('undefined')
63+
})
64+
it('warns on non existing icon', () => {
65+
expect(render(<CIcon name='none'/>))
66+
.toContain('undefined')
67+
})
68+
it('converts toCamelCase', () => {
69+
expect(render(<CIcon name='cif-AU'/>))
70+
.toContain(cifAU[1])
71+
})
4672
})

Diff for: tests/cif-AU.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)