update test case

This commit is contained in:
HeskeyBaozi 2018-08-31 11:41:58 +08:00 committed by 偏右
parent 1cee617a9d
commit ae9aabb1ac

View File

@ -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 <i class="xxx"><svg>...</svg></i>', () => {
@ -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',
]
);
});
});