-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Relates #2
- Loading branch information
abdullahchaudhry
committed
Aug 17, 2017
1 parent
52bb81b
commit ee949d7
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
const test = require('tape'); | ||
const supertest = require('supertest'); | ||
const app = require('./../src/app'); | ||
|
||
// check if tape works | ||
test('1 equals 1', (t) => { | ||
t.equals(1, 1, 'one should equal one'); | ||
t.end(); | ||
}); | ||
|
||
// check if supetest works | ||
test('check if supertest works', (t) => { | ||
supertest(app) | ||
.get('/') | ||
.expect(200) | ||
.expect('Content-Type', /json/) | ||
.end((err, res) => { | ||
t.same(res.statusCode, 200, 'Status code is 200'); | ||
t.end(); | ||
}) | ||
}) | ||
|
||
// check we get 404 on non-existing endpoint | ||
test('404 when endpoint does not exist', (t) => { | ||
supertest(app) | ||
.get('/bsdjkhgablsg') | ||
.expect(404) | ||
.expect('Content-Type', /json/) | ||
.end((err, res) => { | ||
t.same(res.statusCode, 404, 'Status code is 404'); | ||
t.end(); | ||
}) | ||
}) | ||
|
||
test('check prepopulated browse database table', (t) => { | ||
supertest(app) | ||
.get('/browse') | ||
.expect(200) | ||
.expect('Content-Type', /json/) | ||
.end((err, res) => { | ||
let expected = "Movie recommendation app"; | ||
let actual = res; | ||
console.log('res.rows ', res); | ||
t.equals(actual, expected, 'Should be Movie recommendation app') | ||
t.end(); | ||
}) | ||
}) |