Skip to content

Commit b62ae68

Browse files
committed
updates
1 parent 54be6fa commit b62ae68

File tree

12 files changed

+74
-59
lines changed

12 files changed

+74
-59
lines changed

Section-10-React Testing-Jasmin-Mocha-Chai/Mocha-Test/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"directories": {
7-
"test": "test"
7+
"test": "mocha"
88
},
99
"scripts": {
1010
"test": "echo \"Error: no test specified\" && exit 1"
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
describe('#find()', ()=> {
1+
var expect = require('chai').expect;
22

3-
beforeEach(()=>) {
4-
return db.clear()
5-
.then(function() {
6-
return db.save([tobi, loki, jane]);
7-
});
8-
});
3+
describe("A spec (with setup and tear-down)", function() {
4+
it("is just a function, so it can contain any code", function() {
5+
expect(1).toEqual(1);
6+
});
97

10-
describe('#find()', ()=> {
11-
it('respond with matching records', function() {
12-
return db.find({ type: 'User' }).should.eventually.have.length(3);
8+
it("can have more than one expectation", function() {
9+
expect(1).toEqual(1);
10+
expect(true).toEqual(true);
1311
});
14-
});
1512

13+
1614
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = tab
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "Dictionary",
3+
"version": "0.0.1",
4+
"private": true,
5+
"scripts": {
6+
"start": "node node_modules/react-native/local-cli/cli.js start"
7+
},
8+
"dependencies": {
9+
"react": "^15.0.2",
10+
"react-native": "^0.26.3"
11+
}
12+
}

Section-10-React Testing-Jasmin-Mocha-Chai/React Webpack Jasmin Jest Starter/main.js

+2-28
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ var React=require('react');
22
var ReactDOM = require('react-dom');
33
var TestUtils=require('react-addons-test-utils');
44
// jest librray to test react comp
5-
var Component=require('./com.react');
6-
var DemoApp=require('./demoapp');
5+
var Component=require('./src/hello');
6+
var DemoApp=require('./src/demoApp');
77

88

99
describe("test AppComponent props",function(){
@@ -22,32 +22,6 @@ describe("test AppComponent props",function(){
2222
});
2323
});
2424

25-
26-
27-
28-
29-
30-
31-
32-
33-
34-
35-
36-
37-
38-
39-
40-
41-
42-
43-
44-
45-
46-
47-
48-
49-
50-
5125
describe("test helloworld props",function(){
5226
beforeEach(function() {
5327
let helloworld=TestUtils.renderIntoDocument(<Component text='Tarun'></Component>)

Section-10-React Testing-Jasmin-Mocha-Chai/React Webpack Jasmin Jest Starter/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"version": "0.0.0",
44
"description": "Redux counter example",
55
"scripts": {
6-
"start": "webpack-dev-server"
6+
"start": "webpack-dev-server",
7+
"build" : "webpack"
78
},
89
"repository": {
910
"type": "git",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var React=require('react');
2+
3+
var DemoApp=React.createClass({
4+
render:function(){
5+
var text=this.props.text;
6+
return (<div>
7+
<div className="container">Example </div>
8+
<ul>
9+
<li>hello User {this.props.name}</li>
10+
<li>hello User {this.props.name}</li>
11+
</ul>
12+
</div>);
13+
}
14+
})
15+
module.exports=DemoApp;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var React=require('react');
2+
3+
4+
var Hello=React.createClass({
5+
render:function(){
6+
var text=this.props.text;
7+
return (
8+
<div>
9+
{"hello"+text}
10+
<ul className="container"></ul>
11+
</div>);
12+
}
13+
})
14+
module.exports=Hello;

Section-10-React Testing-Jasmin-Mocha-Chai/gulp-jasmine-master/gulpfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ gulp.task('jasmine_unitTesting', function () {
2222
});
2323

2424
gulp.task('watch', function () {
25-
gulp.watch('./*.js',['jasmine_unitTesting']);
25+
gulp.watch('./**/*.js',['jasmine_unitTesting']);
2626
});
2727

28-
gulp.task('default', ['webserver','watch']);
28+
gulp.task('default', ['webserver','watch','jasmine_unitTesting']);
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
var multiply = require('./src/multiply');
2-
31

42
describe('multiply', function(){
53
it('Multiplies two numbers', function(){
6-
expect(multiply(2,3)).toEqual(6);
4+
expect((2+3)).toEqual(5);
75
});
86
});
97

108
describe('multiply', function(){
119
it('Multiplies two numbers', function(){
12-
expect(multiply(2,3)).toEqual(6);
10+
expect((4+4)).toEqual(8);
1311
});
1412
});
1513

Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
import React from 'react';
22

3-
43
class Hello extends React.Component {
5-
64
handleClick(event) {
75
this.setState({honorific: 'Overlord'})
86
}
9-
107
constructor(props) {
118
super(props);
129
this.state = {honorific: 'Captain'};
1310
}
14-
1511
render() {
1612
return <h1 onClick={this.handleClick.bind(this)}>Hello {this.state.honorific} {this.props.name}</h1>;
1713
}
1814
}
1915

20-
2116
export default Hello;

Section-11-React Jest Test/Rest-Jest shallow-Render/module/test.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ const test = addAssertions(tape, {jsxEquals});
1111

1212

1313
test('Hello Component', (t) => {
14-
const renderer = createRenderer();
15-
14+
const renderer = createRenderer(); //step 01
1615
// initial rendering
17-
renderer.render(<Hello name="Jim Bob" />);
18-
let actualElement = renderer.getRenderOutput();
16+
renderer.render(<Hello name="Jim Bob" />); // step 02
17+
let actualElement = renderer.getRenderOutput(); //step 03
1918
let expectedElement = <h1 onClick={function noRefCheck() {}}>Hello Captain Jim Bob</h1>;
20-
2119
// simulate click
2220
renderer.getRenderOutput().props.onClick();
2321
let clickedElement = renderer.getRenderOutput();
2422
let clickedExpectedElement = <h1 onClick={function noRefCheck() {}}>Hello Overlord Jim Bob</h1>
25-
2623
// fail cakes
2724
let unexpectedElement = <h1>Hello Private Jim Bob</h1>;
28-
2925
// compare output with the expected result:
3026
t.jsxEquals(actualElement, expectedElement, "this should work");
3127
t.jsxEquals(clickedElement, clickedExpectedElement, "this should work");

0 commit comments

Comments
 (0)