Skip to content

Commit

Permalink
Add test cases of module Affix and Breadcrumb (#18)
Browse files Browse the repository at this point in the history
* input test  (#8)

* Update README.md

* TagGroup 动态添加数据 点击删除无法获取相应数据问题

* Update README.md

* input test

* 合并

* input test2 (#9)

* Update README.md

* TagGroup 动态添加数据 点击删除无法获取相应数据问题

* Update README.md

* input test

* 合并

* input test2

* Adding default value of porps size on module Avatar and some test cases.

* fix(affix): Fix bug where body.scrollTop is 0.

* InputNumber add defaultValue (#11)

InputNumber add defaultValue, add test case.

* Remove extraneous props `status` from doc and add test cases.

* Add test cases of Breadcrumb

* Add test cases of Affix

* Remove console log
  • Loading branch information
Xing-He authored and jaywcjlove committed Nov 16, 2017
1 parent c459fe7 commit 18e123b
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 8 deletions.
19 changes: 19 additions & 0 deletions src/affix/__test__/Affix.test.js
@@ -0,0 +1,19 @@
import React from 'react';
import { mount } from 'enzyme';
import Affix from '../';


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

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

it('The default performance should be fixed at top 0', () => {
Component.setState({ position: 'fixed', top: 0 })
expect(Component.state().position).toBe('fixed')
expect(Component.state().top).toEqual(0)
Component.setState({ position: null, top: null })
});
});
34 changes: 34 additions & 0 deletions src/breadcrumb/__test__/Breadcrumb.test.js
@@ -0,0 +1,34 @@
import React from 'react';
import { mount } from 'enzyme';
import Breadcrumb from '../';


describe('<Breadcrumb>', () => {
const Component = mount(<Breadcrumb>
<Breadcrumb.Item href="https://uiw-react.github.io">首页</Breadcrumb.Item>
<Breadcrumb.Item separator="#">活动管理</Breadcrumb.Item>
<Breadcrumb.Item>活动列表</Breadcrumb.Item>
<Breadcrumb.Item>活动详情</Breadcrumb.Item>
</Breadcrumb>)

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

it('The length of breadcrumb item should be 4', () => {
expect(Component.find('.w-breadcrumb-item')).toHaveLength(4)
});

it('The separator should be charactor "@"', () => {
Component.setProps({ separator: '@' })
expect(Component.find('.w-breadcrumb-item-separator').at(0).text()).toBe('@')
});

it('The item separator should be charactor "#"', () => {
expect(Component.find('.w-breadcrumb-item-separator').at(1).text()).toBe('#')
});

it('The href of item first should be "https://uiw-react.github.io"', () => {
expect(Component.find('.w-breadcrumb-item a').prop('href')).toEqual('https://uiw-react.github.io')
});
});
15 changes: 7 additions & 8 deletions src/input-number/__test__/InputNumber.test.js
Expand Up @@ -2,18 +2,17 @@ import React from 'react';
import { mount } from 'enzyme';
import { InputNumber } from '../../../src';

describe('<InputNumber>',()=>{
describe('<InputNumber>', () => {
const wrapperState = {
value:0,
value: 0,
}
var wrapper = mount(<InputNumber
onChange={(e,value)=>{
console.log('value:',value)
wrapperState.value=value
onChange={(e, value) => {
wrapperState.value = value
}}
></InputNumber>);
></InputNumber>);

it('Test the default props and node.',() => {
it('Test the default props and node.', () => {
expect(wrapper.name()).toBe('InputNumber')
// 默认值测试
expect(wrapper.find('.w-input-number')).toHaveLength(1);
Expand All @@ -23,7 +22,7 @@ describe('<InputNumber>',()=>{
expect(wrapper.find('.w-input').type()).toBe('div');
})

it('Test onChange attributes.', () => {
it('Test onChange attributes.', () => {
wrapper.setProps({ step: 2 });
let push = wrapper.find('.w-input-number-push').at(0)
push.simulate('click');
Expand Down

0 comments on commit 18e123b

Please sign in to comment.