-
-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/uiw-react/uiw
- Loading branch information
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import Button from '../'; | ||
|
||
describe('<Button>', () => { | ||
const Component = mount(<Button icon="arrow-down"> Normal</Button >) | ||
|
||
it('The name of module must be "Button"', () => { | ||
expect(Component.name()).toBe('Button') | ||
}); | ||
|
||
it('The props size should be one of ["large","default","small","mini"]', () => { | ||
expect(["large", "default", "small", "mini"]).toContain(Component.prop('size')) | ||
}); | ||
|
||
it('The props type should be one of ["default", "primary", "success", "info", "warn", "error", "danger", "link"]', () => { | ||
expect(["default", "primary", "success", "info", "warn", "error", "danger", "link"]).toContain(Component.prop('type')) | ||
}); | ||
|
||
it('The props htmlType should be one of ["submit","reset","button"]', () => { | ||
expect(["submit", "reset", "button"]).toContain(Component.prop('htmlType')) | ||
}); | ||
|
||
it('Should an `icon` can be found in button', () => { | ||
expect(Component.find('.w-icon-arrow-down')).toHaveLength(1) | ||
}); | ||
|
||
it('Should class `block` can be found in button', () => { | ||
Component.setProps({ block: true }) | ||
expect(Component.find('button.w-btn').hasClass('block')).toBe(true) | ||
Component.setProps({ block: false }) | ||
}); | ||
|
||
it('Button can\'t be Click when props disabled or loading is true', () => { | ||
let shouldBeFalse = false; | ||
Component.setProps({ | ||
disabled: true, | ||
onClick: () => { | ||
shouldBeFalse = true; | ||
} | ||
}) | ||
expect(Component.prop('disabled')).toBe(true) | ||
Component.find('button').simulate('click') | ||
expect(shouldBeFalse).toBe(false) | ||
|
||
Component.setProps({ | ||
disabled: false, | ||
loading: true | ||
}) | ||
Component.find('button').simulate('click') | ||
expect(shouldBeFalse).toBe(false) | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import { Loading } from '../../../src'; | ||
|
||
|
||
describe('<Loading>', () => { | ||
var wrapper = mount(<Loading></Loading>); | ||
|
||
it('Test the default props and node.',() => { | ||
expect(wrapper.name()).toBe('Loading'); | ||
// 默认值测试 | ||
expect(wrapper.find('.w-loading')).toHaveLength(1); | ||
expect(wrapper.type()).toEqual(Loading); | ||
expect(wrapper.at(0).prop('prefixCls')).toBe('w-loading'); | ||
expect(wrapper.at(0).prop('loading')).toBe(true); | ||
expect(wrapper.at(0).prop('size')).toBe('default'); | ||
}) | ||
|
||
it('Test size attributes.', () => { | ||
wrapper.setProps({ size: 'large' }); | ||
expect(wrapper.find('.w-loading').at(0).prop('className')).toBe('w-loading w-loading-large'); | ||
}); | ||
|
||
it('Test tip attributes.', () => { | ||
wrapper.setProps({ tip: '正在哈哈哈' }); | ||
let loading = wrapper.find('.w-loading').at(0); | ||
expect(loading.html()).toContain('<div class="w-loading w-loading-large"><div class="w-loading-tips"><div class="w-loading-tips-nested"><div class="w-loading-icon"></div>正在哈哈哈</div></div></div>'); | ||
}); | ||
|
||
}) |