File tree Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Expand file tree Collapse file tree 4 files changed +38
-3
lines changed Original file line number Diff line number Diff line change 1
- node_modules
1
+ node_modules
2
+ .vscode
Original file line number Diff line number Diff line change 1
- # javascript-repl
1
+ # Javascript REPL
2
+
3
+ * npm test
Original file line number Diff line number Diff line change 1
1
const chai = require ( 'chai' ) ;
2
2
const expect = chai . expect ;
3
+ const chaiHttp = require ( 'chai-http' ) ;
4
+
5
+ chai . use ( chaiHttp ) ;
6
+
7
+
8
+ const foo = ( name ) => `Hi there, ${ name } ` ;
3
9
4
10
describe ( 'Object' , function ( ) {
5
11
@@ -15,4 +21,29 @@ describe('Object', function () {
15
21
done ( ) ;
16
22
} ) ;
17
23
24
+ } ) ;
25
+
26
+ describe ( 'Function' , function ( ) {
27
+
28
+ it ( 'should return a greeting message with name passed as an argument' , function ( done ) {
29
+
30
+ expect ( foo ( 'John' ) ) . to . equal ( 'Hi there, John' ) ;
31
+ done ( ) ;
32
+ } ) ;
33
+
34
+ } ) ;
35
+
36
+ describe ( 'Fake JSON Placeholder' , function ( ) {
37
+
38
+ it ( 'should return 200 and array of objects' , function ( done ) {
39
+ chai . request ( 'https://jsonplaceholder.typicode.com' )
40
+ . get ( '/users' )
41
+ . end ( function ( err , res ) {
42
+ expect ( res ) . to . have . status ( 200 ) ;
43
+ expect ( res . body ) . to . be . a ( 'array' ) ;
44
+ expect ( res . body [ 0 ] . name ) . to . eql ( 'Leanne Graham' ) ;
45
+ done ( ) ;
46
+ } ) ;
47
+ } ) ;
48
+
18
49
} ) ;
Original file line number Diff line number Diff line change 4
4
"description" : " " ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
- "test" : " echo \" Error: no test specified \" && exit 1 "
7
+ "test" : " mocha app.js "
8
8
},
9
9
"author" : " " ,
10
10
"license" : " ISC" ,
11
11
"devDependencies" : {
12
12
"chai" : " ^3.5.0" ,
13
+ "chai-http" : " ^3.0.0" ,
13
14
"mocha" : " ^3.1.0"
14
15
}
15
16
}
You can’t perform that action at this time.
0 commit comments