diff --git a/__tests__/BootstrapTable-test.js b/__tests__/BootstrapTable-test.js new file mode 100644 index 000000000..401eddbb0 --- /dev/null +++ b/__tests__/BootstrapTable-test.js @@ -0,0 +1,22 @@ +jest.dontMock('../src/BootstrapTable.js'); +jest.dontMock('../src/TableHeaderColumn.js'); +jest.dontMock('../src/TableBody.js'); +jest.dontMock('../src/TableColumn.js'); +jest.dontMock('../src/TableHeader.js'); +jest.dontMock('../src/TableRow.js'); +jest.dontMock('../src/pagination/PaginationList.js'); +jest.dontMock('../src/pagination/PageButton.js'); + +describe('BootstrapTable', function() { + var testData = [ + {id: 1, name: "name1", price: 100}, + {id: 2, name: "name2", price: 120}, + {id: 3, name: "name3", price: 130}, + {id: 4, name: "name4", price: 140}, + {id: 5, name: "name5", price: 110} + ]; + + it('init', function() { + + }); +}); diff --git a/__tests__/TableHeaderColumn-test.js b/__tests__/TableHeaderColumn-test.js new file mode 100644 index 000000000..24ce8c7a7 --- /dev/null +++ b/__tests__/TableHeaderColumn-test.js @@ -0,0 +1,52 @@ +jest.dontMock('../src/BootstrapTable.js'); +jest.dontMock('../src/TableHeaderColumn.js'); +jest.dontMock('../src/TableBody.js'); +jest.dontMock('../src/TableColumn.js'); +jest.dontMock('../src/TableHeader.js'); +jest.dontMock('../src/TableRow.js'); +jest.dontMock('../src/pagination/PaginationList.js'); +jest.dontMock('../src/pagination/PageButton.js'); + +describe('TableHeaderColumn Test', function() { + + var React; + var TestUtils; + var ReactTestUtils; + var TableHeaderColumn; + + beforeEach(function(){ + React = require('react/addons'); + TableHeaderColumn = require('../src/TableHeaderColumn.js'); + TestUtils = React.addons.TestUtils; + ReactTestUtils = React.addons.ReactTestUtils; + }); + + it('A basic table header column test', function() { + + var idHeaderColumn = TestUtils.renderIntoDocument( + Product ID + ); + + expect(idHeaderColumn.props.dataField).toEqual("id"); + expect(idHeaderColumn.props.children).toEqual("Product ID"); + expect(idHeaderColumn.props.dataAlign).toEqual("left"); + expect(idHeaderColumn.props.dataSort).toEqual(false); + expect(idHeaderColumn.props.dataFormat).toBe(undefined); + + + var reactThElm = TestUtils.findRenderedDOMComponentWithTag(idHeaderColumn, 'th'); + expect(reactThElm).not.toBe(null); + var th = reactThElm.getDOMNode(); + expect(th.className).toEqual(""); + expect(th.childNodes.length).toEqual(1); + + var reactDivElm = TestUtils.findRenderedDOMComponentWithTag(idHeaderColumn, 'div'); + expect(reactDivElm).not.toBe(null); + var div = reactDivElm.getDOMNode(); + expect(div.className).toEqual("th-inner table-header-column"); + expect(div.textContent).toEqual("Product ID"); + + // ReactTestUtils.Simulate.click(reactDivElm); + // expect(th.getDOMNode()).toEqual(0); + }); +}); diff --git a/package.json b/package.json index 4eb3b2920..ce0612339 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "url": "https://github.com/AllenFang/react-bootstrap-table.git" }, "scripts": { - "test": "Not yet implements." + "test": "jest" }, "keywords": [ "react", @@ -43,8 +43,6 @@ }, "jest": { "scriptPreprocessor": "/preprocessor.js", - "unmockedModulePathPatterns": [ - "/node_modules/react" - ] + "unmockedModulePathPatterns": ["/node_modules/react"] } } diff --git a/preprocessor.js b/preprocessor.js index 059200940..f1ebc623e 100644 --- a/preprocessor.js +++ b/preprocessor.js @@ -1,7 +1,13 @@ -// var ReactTools = require('react-tools'); var babel = require("babel"); module.exports = { - process: function(src) { - return babel.transform(src, { blacklist: ["react"] }).code; + process: function(src, filename) { + if (!babel.canCompile(filename)) { + return ''; + } + // Ignore all files within node_modules + if (filename.indexOf('node_modules') === -1) { + return babel.transform(src, {filename: filename}).code;; + } + return src; } };