forked from weui/react-weui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcell.js
56 lines (45 loc) · 1.79 KB
/
cell.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/**
* Created by jf on 15/12/9.
*/
"use strict";
import React from 'react';
import { shallow } from 'enzyme';
import assert from 'assert';
import WeUI from '../src/index';
const {Cell, CellHeader, CellBody, CellFooter} = WeUI;
describe('<Cell></Cell>', ()=> {
[undefined, null, 'custom_class'].map((clazz) => {
describe(`<Cell className="${clazz}"></Cell>`, ()=>{
const header = <CellHeader><img src="http://mmrmb.github.io/avatar/bear.jpg" alt=""/></CellHeader>;
const body = <CellBody><div><h2 className="title">标题</h2><p className="desc">描述</p></div></CellBody>;
const footer = <CellFooter>footer</CellFooter>;
const wrapper = shallow(
<Cell className={clazz}>
{header}
{body}
{footer}
</Cell>
);
it(`should render <Cell></Cell> component `, ()=>{
assert(wrapper.instance() instanceof Cell);
});
it(`should have 'weui_cell' class name`, ()=>{
assert(wrapper.hasClass(`weui_cell`));
});
it(`should have custom class name ${clazz} when className is not null or empty`, ()=>{
if (clazz) {
assert(wrapper.hasClass(clazz));
}
});
it(`should have header child`, ()=>{
assert(shallow(header).html() === wrapper.find(CellHeader).html());
});
it(`should have body child`, ()=>{
assert(shallow(body).html() === wrapper.find(CellBody).html());
});
it(`should have footer child`, ()=>{
assert(shallow(footer).html() === wrapper.find(CellFooter).html());
});
});
});
});