From 862d987fb17a9058064ac20509bc0029d034eade Mon Sep 17 00:00:00 2001 From: progrape Date: Wed, 23 Dec 2015 13:50:59 +0800 Subject: [PATCH] =?UTF-8?q?#15=20`Cells`=E5=85=81=E8=AE=B8=E4=BC=A0?= =?UTF-8?q?=E5=85=A5=E8=87=AA=E5=AE=9A=E4=B9=89className?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/cell/cells.js | 9 +++++---- test/cells.js | 17 +++++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/components/cell/cells.js b/src/components/cell/cells.js index 1d3d5ad..e0b50a8 100644 --- a/src/components/cell/cells.js +++ b/src/components/cell/cells.js @@ -9,15 +9,16 @@ import classNames from 'classnames'; export default class Cells extends React.Component { render() { - const {children, access, radio, checkbox, form, ...others} = this.props; - const className = classNames({ + const {children, className, access, radio, checkbox, form, ...others} = this.props; + const cls = classNames({ weui_cells: true, weui_cells_access: access, - weui_cells_form: form + weui_cells_form: form, + [className]: className }); return ( -
{children}
+
{children}
); } }; \ No newline at end of file diff --git a/test/cells.js b/test/cells.js index ed461ab..ff94c53 100644 --- a/test/cells.js +++ b/test/cells.js @@ -14,27 +14,32 @@ const {Cells, Cell, CellHeader, CellBody, CellFooter} = WeUI; describe('', ()=> { [true, false].map((access) => { - describe(``, ()=>{ + describe(``, ()=> { const child = headerbodyfooter; + const customClassName = 'customClassName1 customClassName2'; const wrapper = shallow( - {child} + {child} ); - it(`should render component `, ()=>{ + it(`should render component `, ()=> { assert(wrapper.instance() instanceof Cells); }); - it(`should have 'weui_cells' class name`, ()=>{ + it(`should have 'weui_cells' class name`, ()=> { assert(wrapper.hasClass(`weui_cells`)); }); - it(`should have 'weui_cells_access' when access attribute is true`, ()=>{ + it(`should have custom class name ${customClassName}`, ()=> { + assert(wrapper.hasClass(customClassName)); + }); + + it(`should have 'weui_cells_access' when access attribute is true`, ()=> { if (access) { assert(wrapper.hasClass(`weui_cells_access`)); } }); - it(`should have child typeof Cell`, ()=>{ + it(`should have child typeof Cell`, ()=> { assert(wrapper.find(Cell).html() === shallow(child).html()); }); });