diff --git a/components/table/__tests__/Table.test.js b/components/table/__tests__/Table.test.js index 1e140a863..99de5bf29 100644 --- a/components/table/__tests__/Table.test.js +++ b/components/table/__tests__/Table.test.js @@ -5,22 +5,22 @@ import Vue from 'vue'; const { Column, ColumnGroup } = Table; describe('Table', () => { - it('renders JSX correctly', done => { - const data = [ - { - key: '1', - firstName: 'John', - lastName: 'Brown', - age: 32, - }, - { - key: '2', - firstName: 'Jim', - lastName: 'Green', - age: 42, - }, - ]; + const data = [ + { + key: '1', + firstName: 'John', + lastName: 'Brown', + age: 32, + }, + { + key: '2', + firstName: 'Jim', + lastName: 'Green', + age: 42, + }, + ]; + it('renders JSX correctly', done => { const wrapper = mount( { render() { @@ -96,4 +96,34 @@ describe('Table', () => { done(); }); }); + + it('align column should not override cell style', () => { + const columns = [ + { title: 'Name', dataIndex: 'name', key: 'name' }, + { + title: 'Age', + dataIndex: 'age', + key: 'age', + align: 'center', + customCell: (record, rowIndex) => { + return { + style: { + color: 'red', + }, + }; + }, + }, + ]; + const wrapper = mount(Table, { + propsData: { + columns, + dataSource: data, + }, + sync: false, + }); + Vue.nextTick(() => { + expect(wrapper.html()).toMatchSnapshot(); + done(); + }); + }); }); diff --git a/components/table/__tests__/__snapshots__/Table.test.js.snap b/components/table/__tests__/__snapshots__/Table.test.js.snap index cf3f43fab..ec3f70a0f 100644 --- a/components/table/__tests__/__snapshots__/Table.test.js.snap +++ b/components/table/__tests__/__snapshots__/Table.test.js.snap @@ -1,5 +1,61 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Table align column should not override cell style 1`] = ` +
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
+
Name
+
+
Age
+
+ + 32
+ + 42
+
+
+
+ +
+
+
+`; + exports[`Table renders JSX correctly 1`] = `
diff --git a/components/vc-table/src/TableCell.jsx b/components/vc-table/src/TableCell.jsx index fc6d5b1e4..3efa16a6b 100644 --- a/components/vc-table/src/TableCell.jsx +++ b/components/vc-table/src/TableCell.jsx @@ -97,7 +97,7 @@ export default { return null; } if (column.align) { - tdProps.style = { textAlign: column.align }; + tdProps.style = { ...tdProps.style, textAlign: column.align }; } return (