@@ -3,10 +3,16 @@ import React from 'react'
3
3
import { renderToStaticMarkup as render } from 'react-dom/server'
4
4
5
5
import CIcon from 'src/'
6
+ import CIconRaw from 'src/'
6
7
import { logo , logo as cilLogo } from './logo'
7
- React . icons = { logo, cilLogo }
8
+ import { cifAU } from './cif-AU' ;
9
+ React . icons = { logo, cilLogo, cifAU }
8
10
9
11
describe ( 'CIcon' , ( ) => {
12
+
13
+ // polyfill
14
+ String . prototype . replaceAll = function ( f , r ) { return this . split ( f ) . join ( r ) ; }
15
+
10
16
it ( 'renders svg with class="c-icon"' , ( ) => {
11
17
expect ( render ( < CIcon /> ) )
12
18
. toContain ( 'class="c-icon' )
@@ -43,4 +49,24 @@ describe('CIcon', () => {
43
49
expect ( render ( < CIcon use = 'xxx' /> ) )
44
50
. toContain ( '<use href="xxx"></use></svg>' )
45
51
} )
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
+ } )
46
72
} )
0 commit comments