diff --git a/components/icon/__tests__/index.test.js b/components/icon/__tests__/index.test.js index 0cf96cf073..ab73daf488 100644 --- a/components/icon/__tests__/index.test.js +++ b/components/icon/__tests__/index.test.js @@ -1,6 +1,7 @@ import React from 'react'; import { render } from 'enzyme'; import Icon from '..'; +import { getThemeFromTypeName, withThemeSuffix } from '../utils'; describe('Icon', () => { it('should render to a ...', () => { @@ -148,3 +149,33 @@ describe('Icon.createFromIconfontCN()', () => { expect(wrapper).toMatchSnapshot(); }); }); + +describe('utils', () => { + it('getThemeFromTypeName() should work', () => { + const testCases = ['check-circle', 'check-circle-o', 'check-circle-fill', 'check-circle-twotone']; + const result = testCases.map(type => getThemeFromTypeName(type)); + expect(result).toEqual( + [null, 'outlined', 'filled', 'twoTone'] + ); + }); + + it('withThemeSuffix() should work', () => { + const testCases = [ + { type: 'home', theme: 'filled' }, + { type: 'home', theme: 'outlined' }, + { type: 'home', theme: 'twoTone' }, + { type: 'home', theme: 'This-is-the-secret' }, + { type: 'home-o', theme: 'filled' }, + { type: 'home-fill', theme: 'outlined' }, + { type: 'home-o', theme: 'twoTone' }, + { type: 'home-o', theme: 'This-is-the-secret' }, + ]; + const result = testCases.map(({ type, theme }) => withThemeSuffix(type, theme)); + expect(result).toEqual( + [ + 'home-fill', 'home-o', 'home-twotone', 'home', + 'home-o', 'home-fill', 'home-o', 'home-o', + ] + ); + }); +});