diff --git a/.babelrc b/.babelrc
new file mode 100644
index 00000000..6e11f359
--- /dev/null
+++ b/.babelrc
@@ -0,0 +1,6 @@
+{
+ "presets": [
+ "react",
+ "es2015"
+ ]
+}
diff --git a/.gitignore b/.gitignore
index daeba5f9..c54c05c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
*~
node_modules
.DS_Store
+.idea/
diff --git a/LICENSE b/LICENSE
old mode 100644
new mode 100755
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
index 4862f5df..8ebebad6
--- a/README.md
+++ b/README.md
@@ -53,3 +53,9 @@ You can change the port number by setting the `$PORT` environment variable befor
```sh
PORT=3001 node server.js
```
+
+## Testing
+
+```sh
+npm test
+```
diff --git a/__tests__/example-test.js b/__tests__/example-test.js
new file mode 100644
index 00000000..931c2d77
--- /dev/null
+++ b/__tests__/example-test.js
@@ -0,0 +1,34 @@
+jest.unmock('../public/scripts/example.js');
+
+var React = require('react');
+var ReactDOM = require('react-dom');
+var ReactTestUtils = require('react-addons-test-utils');
+var CommentBoxComponent = require('../public/scripts/example.js');
+
+var CommentBox = CommentBoxComponent.CommentBox;
+
+describe('TestCommentBoxComponent', () => {
+ var boxNode;
+ var commentBox;
+ beforeEach(() => {
+ commentBox = ReactTestUtils.renderIntoDocument(
+
+ );
+ boxNode = ReactDOM.findDOMNode(commentBox);
+ });
+
+ it('should exists', function() {
+ expect(ReactTestUtils.isCompositeComponent(commentBox)).toBeTruthy();
+ });
+
+ it('class should equal commentBox', () => {
+ expect(boxNode.className).toEqual('commentBox');
+ });
+
+ it('initial state data should be empty', () => {
+ expect(commentBox.getInitialState()).toBeDefined();
+ const commentBoxData = commentBox.getInitialState().data;
+ expect(commentBoxData).toBeDefined();
+ expect(commentBoxData).toEqual([]);
+ })
+})
diff --git a/app.json b/app.json
old mode 100644
new mode 100755
diff --git a/comments.json b/comments.json
old mode 100644
new mode 100755
index 28816136..375135f9
--- a/comments.json
+++ b/comments.json
@@ -23,5 +23,15 @@
"id": 1464988717637,
"author": "evil",
"text": "alert(1)"
+ },
+ {
+ "id": 1491409415686,
+ "author": "blah",
+ "text": "blah"
+ },
+ {
+ "id": 1491409439269,
+ "author": "testing",
+ "text": "test"
}
]
\ No newline at end of file
diff --git a/package.json b/package.json
index bf3360a0..84858752 100644
--- a/package.json
+++ b/package.json
@@ -6,14 +6,41 @@
"description": "Code from the React tutorial.",
"main": "server.js",
"dependencies": {
+ "babel-jest": "^13.0.0",
+ "babel-preset-es2015": "^6.9.0",
+ "babel-preset-react": "^6.5.0",
"body-parser": "^1.4.3",
- "express": "^4.4.5"
+ "express": "^4.4.5",
+ "jest-cli": "^13.0.0",
+ "jquery": "^3.2.1",
+ "react": "^15.1.0",
+ "react-addons-test-utils": "^15.4.2",
+ "react-dom": "^15.1.0"
+ },
+ "devDependencies": {
+ "babel-preset-react": "^6.5.0",
+ "babelify": "^7.3.0",
+ "jest-cli": "^13.0.0"
},
- "devDependencies": {},
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1",
+ "test": "jest",
"start": "node server.js"
},
+ "jest": {
+ "scriptPreprocessor": "./node_modules/babel-jest",
+ "testFileExtensions": [
+ "es6",
+ "js"
+ ],
+ "moduleFileExtensions": [
+ "js",
+ "json",
+ "es6"
+ ],
+ "unmockedModulePathPatterns": [
+ "./node_modules/react"
+ ]
+ },
"repository": {
"type": "git",
"url": "https://github.com/reactjs/react-tutorial.git"
@@ -29,7 +56,7 @@
"url": "https://github.com/reactjs/react-tutorial/issues"
},
"homepage": "https://github.com/reactjs/react-tutorial",
- "engines" : {
- "node" : "0.12.x"
+ "engines": {
+ "node": "0.12.x"
}
}
diff --git a/public/css/base.css b/public/css/base.css
old mode 100644
new mode 100755
diff --git a/public/index.html b/public/index.html
old mode 100644
new mode 100755
index eb201204..0b4d4f84
--- a/public/index.html
+++ b/public/index.html
@@ -13,10 +13,11 @@
-
+
+