diff --git a/jest-preprocessor.js b/jest-preprocessor.js new file mode 100644 index 0000000000..2637772f52 --- /dev/null +++ b/jest-preprocessor.js @@ -0,0 +1,7 @@ +// preprocessor.js +var ReactTools = require('react-tools'); +module.exports = { + process: function(src) { + return ReactTools.transform(src); + } +}; \ No newline at end of file diff --git a/package.json b/package.json index 66efbe18e2..9602bc377f 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "test-bamboo-ci": "mocha test test/*", "coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec", "coverage-report": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage", - "postinstall": "npm run build" + "postinstall": "npm run build", + "jest": "jest" }, "dependencies": { "bluebird": "2.2.2", @@ -50,13 +51,20 @@ "chai": "1.9.1", "coveralls": "^2.11.2", "istanbul": "0.3.2", + "jest-cli": "^0.1.18", "jshint": "2.5.2", "mocha": "1.20.1", "mocha-lcov-reporter": "0.0.1", "mockery": "1.4.0", "pre-commit": "0.0.9", + "react-tools": "^0.12.0", "supertest": "0.13.0", "supervisor": "0.6.0", "xmlbuilder": "2.4.4" + }, + "jest": { + "scriptPreprocessor": "/jest-preprocessor.js", + "unmockedModulePathPatterns": ["/node_modules/react"], + "moduleFileExtensions": ["jsx", "js"] } } diff --git a/public/js/__tests__/Menu-test.js b/public/js/__tests__/Menu-test.js new file mode 100644 index 0000000000..deffe6b9c4 --- /dev/null +++ b/public/js/__tests__/Menu-test.js @@ -0,0 +1,14 @@ +/** @jsx React.DOM */ + +jest.dontMock("../components/Menu"); + +var Menu = require("../components/Menu"); +var React = require("react/addons"); +var TestUtils = React.addons.TestUtils; + +describe('Menu test', function () { + it('should include unleash in menu', function () { + var Compononent = TestUtils .renderIntoDocument(); + expect(Compononent.getDOMNode().textContent).toMatch('unleash'); + }); +}); \ No newline at end of file