8000 added chai-http · agjs/javascript-repl@8ba5d0a · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ba5d0a

Browse files
committed
added chai-http
1 parent ce8fb9e commit 8ba5d0a

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
.vscode

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
# javascript-repl
1+
# Javascript REPL
2+
3+
* npm test

app.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
const chai = require('chai');
22
const expect = chai.expect;
3+
const chaiHttp = require('chai-http');
4+
5+
chai.use(chaiHttp);
6+
7+
8+
const foo = (name) => `Hi there, ${name}`;
39

410
describe('Object', function () {
511

@@ -15,4 +21,29 @@ describe('Object', function () {
1521
done();
1622
});
1723

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+
1849
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
7+
"test": "mocha app.js"
88
},
99
"author": "",
1010
"license": "ISC",
1111
"devDependencies": {
1212
"chai": "^3.5.0",
13+
"chai-http": "^3.0.0",
1314
"mocha": "^3.1.0"
1415
}
1516
}

0 commit comments

Comments
 (0)
0