Skip to content

Commit d81ff8d

Browse files
committed
fix urls in tests, add closing brackets
1 parent 6ea8701 commit d81ff8d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎day8/superagent_testing.md‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('Notes JSON api', function() {
2020

2121
//testing the POST function of the JSON API
2222
it('can successfully create a new note', function(done) {
23-
superagent.post('http://localhost:3000/api/v1/notes/)
23+
superagent.post('http://localhost:3000/api/v1/notes/')
2424
.send({
2525
body: 'a new note!'
2626
})
@@ -36,7 +36,7 @@ describe('Notes JSON api', function() {
3636

3737
//testing the GET function of the JSON API
3838
it('can successfully get a note', function(done) {
39-
superagent.get('http://localhost:3000/api/v1/notes/' + id)
39+
superagent.get('http://localhost:3000/api/v1/note/' + id)
4040
.end(function(err, res) {
4141
expect(err).to.eql(null);
4242
expect(res.body._id).to.be.eql(id);
@@ -47,7 +47,7 @@ describe('Notes JSON api', function() {
4747
});
4848

4949
it('can successfully update a note', function(done) {
50-
superagent.put('http://localhost:3000/api/v1/notes/' + id)
50+
superagent.put('http://localhost:3000/api/v1/note/' + id)
5151
.send({
5252
body: 'an updated note'
5353
})
@@ -61,12 +61,13 @@ describe('Notes JSON api', function() {
6161
});
6262

6363
it('can successfully delete a note', function(done) {
64-
superagent.del('http://localhost:3000/api/v1/notes/' + id)
64+
superagent.del('http://localhost:3000/api/v1/note/' + id)
6565
.end(function(err, res) {
6666
expect(err).to.eql(null);
6767

6868
done();
6969
});
7070
});
71+
});
7172
```
7273
Some interesting things happen in this code, first when app is required from server.js it actually starts the server before sending JSON requests to it. When each request is sent to the server it returns a callback response that should contain a successful JSON object. In the case of the creation of this object(the POST request) it returns a copy of the object that presumably has been saved to a persistent database. It's integration testing, so while it's not precise it does test the general use case for the JSON api.```')})})```

0 commit comments

Comments
 (0)