@@ -3,10 +3,16 @@ import React from 'react'
33import { renderToStaticMarkup as render } from 'react-dom/server'
44
55import CIcon from 'src/'
6+ import CIconRaw from 'src/'
67import { logo , logo as cilLogo } from './logo'
7- React . icons = { logo, cilLogo }
8+ import { cifAU } from './cif-AU' ;
9+ React . icons = { logo, cilLogo, cifAU }
810
911describe ( '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} )
0 commit comments