Skip to content

Commit

Permalink
Adding default value of porps size on module Avatar and some test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
Xing-He authored and jaywcjlove committed Nov 13, 2017
1 parent 3eb889b commit b24b5fe
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/avatar/__test__/Avatar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { mount } from 'enzyme';
import Avatar from '../';

describe('<Avatar>', () => {
const Component = mount(<Avatar />);

it('The name of module must be Avatar', () => {
expect(Component.name()).toBe('Avatar');
})

it('The type of props "type" should be string', () => {
Component.setProps({ icon: 'user' })
expect(typeof Component.prop('icon')).toEqual('string');
})

it('The type of props "type" should be "Element"', () => {
Component.setProps({ icon: <div>This is a Dom Element</div> })
expect(Component.prop('icon').type).toEqual('div')
})

it('The value of props "size" must be one of ["large", "default", "small"]', () => {
expect(["large", "default", "small"]).toContain(Component.prop('size'))
})

it('The value of props "shape" must be one of ["square","circle"]', () => {
expect(["square", "circle"]).toContain(Component.prop('shape'))
})
})
1 change: 1 addition & 0 deletions src/avatar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ Avatar.propTypes = {
Avatar.defaultProps = {
prefixCls: 'w-avatar',
shape: 'circle',
size: 'default'
}

0 comments on commit b24b5fe

Please sign in to comment.