|
1 | 1 | import expect from 'expect'
|
2 | 2 | import React from 'react'
|
3 |
| -import {renderToStaticMarkup as render} from 'react-dom/server' |
| 3 | +import { renderToStaticMarkup as render } from 'react-dom/server' |
4 | 4 |
|
5 |
| -import {CIcon} from 'src/' |
| 5 | +import CIcon from 'src/' |
| 6 | +import {logo, logo as cilLogo} from './logo' |
| 7 | +React.icons = { logo, cilLogo } |
6 | 8 |
|
7 | 9 | describe('CIcon', () => {
|
8 | 10 | it('renders svg with class="c-icon"', () => {
|
9 | 11 | expect(render(<CIcon/>))
|
10 | 12 | .toContain('class="c-icon')
|
11 | 13 | })
|
12 |
| - it('renders svg with class="c-icon-xl"', () => { |
13 |
| - expect(render(<CIcon size={'xl'}/>)) |
14 |
| - .toContain(' c-icon-xl') |
| 14 | + it('renders svg with name', () => { |
| 15 | + expect(render(<CIcon name='logo'/>)) |
| 16 | + .toContain(logo[1]) |
| 17 | + }) |
| 18 | + it('renders svg with name and className', () => { |
| 19 | + expect(render(<CIcon name={'logo'} className='test'/>)) |
| 20 | + .toContain(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${logo[0]}" class="c-icon test" role="img">${logo[1]}</svg>`) |
| 21 | + }) |
| 22 | + it('renders svg with content', () => { |
| 23 | + expect(render(<CIcon content='content'/>)) |
| 24 | + .toContain('role="img">content</svg>') |
| 25 | + }) |
| 26 | + it('renders svg with size', () => { |
| 27 | + expect(render(<CIcon size='xl'/>)) |
| 28 | + .toContain('c-icon-xl') |
| 29 | + }) |
| 30 | + it('renders svg with custom size', () => { |
| 31 | + expect(render(<CIcon size='custom'/>)) |
| 32 | + .toContain('c-icon-custom-size') |
| 33 | + }) |
| 34 | + it('renders svg with className', () => { |
| 35 | + expect(render(<CIcon className='c-icon-test'/>)) |
| 36 | + .toContain('c-icon-test') |
| 37 | + }) |
| 38 | + it('renders <img> with src', () => { |
| 39 | + expect(render(<CIcon src='src'/>)) |
| 40 | + .toContain('<img src="src" role="img"/>') |
| 41 | + }) |
| 42 | + it('renders <svg> with <use>', () => { |
| 43 | + expect(render(<CIcon use='xxx'/>)) |
| 44 | + .toContain('<use href="xxx"></use></svg>') |
15 | 45 | })
|
16 | 46 | })
|
0 commit comments