UNPKG

@beisen/dropdown-list

Version:

DropDownList

92 lines (86 loc) 3.09 kB
import React, {Component, PropTypes} from 'react' import DropDownList from '../src/index'; import { shallow, mount, render } from 'enzyme'; const DropDownData = { "title":"测试" //input框前的文字标识,可为空 ,"type":"single" //single 单选 more 多选 ,"children":[ { "id":1 ,"title":"查看详情" ,"isActive":false } ,{ "id":2 ,"title":"性质维度" ,"isActive":false } ,{ "id":3 ,"title":"地域维度" ,"isActive":false } ,{ "id":4 ,"title":"包含下属" ,"isActive":false } ,{ "id":4 ,"title":"包含下属" ,"isActive":false } ,{ "id":4 ,"title":"包含下属" ,"isActive":false } ,{ "id":4 ,"title":"包含下属" ,"isActive":false } ,{ "id":4 ,"title":"包含下属" ,"isActive":false } ,{ "id":4 ,"title":"包含下属" ,"isActive":false } ,{ "id":4 ,"title":"包含下属" ,"isActive":false } ] /** MenuItem **/ ,"hidden":true //是否显示\ ,"disabled":false //是否禁用 ,"onClick":function(val){console.log(val)} /**点击后事件回调**/ ,"onBlur":function(val){console.log(val)} /**失去焦点后事件回调**/ ,"onChange":function(val){console.log(val)} /**change后事件回调**/ ,"onFocus":function(val){console.log(val)} /**获取焦点后事件回调**/ } describe('DropDownList', ()=> { it('render correct', () => { const warpper = render(<DropDownList data={DropDownData}/>); expect(warpper.text()).toEqual("hello world"); }) it('render correct', () => { const dropButton = render(<DropDownList data={DropDownData}/>); expect(dropButton.hasClass('btns')).actual; }) it('open correct', () => { const dropButton = render(<DropDownList data={DropDownData}/>); expect(dropButton.hasClass('drop-down-list-active')).not.actual; }) it('simulates click events', () => { const onButtonClick = jasmine.createSpy('111'); const dropButton = mount(<DropDownList data={DropDownData} bnRipple={onButtonClick}/>); dropButton.simulate('click'); const active = dropButton.state('btnActive'); expect(active).actual; }); })