-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f1288e9
commit 394e88c
Showing
1 changed file
with
45 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,67 @@ | ||
//Require the dev-dependencies | ||
const chai = require('chai') | ||
const request = require('supertest') | ||
// const assert = require('assert') | ||
const expect = chai.expect | ||
const app = require('../index') | ||
|
||
describe('main App', function(){ | ||
describe('get /', function(){ | ||
it('Should return 200 OK with /api url', function(done){ | ||
it('Should return 200 OK with /api uri', function(done){ | ||
request(app) | ||
.get('/') | ||
.set('Accept','application/json') | ||
.expect('Content-Type', /json/) | ||
.expect(200) | ||
.then(res => { | ||
// console.log(res.body) | ||
// console.log(res.headers) | ||
// console.log(res.status) | ||
expect(res.body.newUrl, 'It seems to be NOT Ok').to.match(/\/api/) | ||
done() | ||
}) | ||
.catch(err => done(err)) | ||
}) | ||
}) | ||
|
||
describe('get /api/418', function(){ | ||
it('Shound return 418 http code', function(done){ | ||
request(app) | ||
.get('/api/418') | ||
.set('Accept','application/json') | ||
.expect(418) | ||
.then(res => { | ||
expect(res.body.code, 418) | ||
done() | ||
}) | ||
.catch(err => done(err)) | ||
}) | ||
}) | ||
|
||
describe('get /api/200', function(){ | ||
it('Should return image uri', function(done){ | ||
request(app) | ||
.get('/api/200') | ||
.set('Accept','application/json') | ||
.expect('Content-Type', /json/) | ||
.expect(200) | ||
.then(res => { | ||
expect(res.body.image, 'It seems to be NOT Ok').to.match(/pexels/) | ||
done() | ||
}) | ||
.catch(err => done(err)) | ||
}) | ||
}) | ||
|
||
describe('get /api/400', function(){ | ||
it('Should NOT return image uri', function(done){ | ||
request(app) | ||
.get('/api/400') | ||
.set('Accept','application/json') | ||
.expect('Content-Type', /json/) | ||
.expect(400) | ||
.then(res => { | ||
expect(res.body, 'It seems to be NOT Ok').to.not.match(/image/) | ||
done() | ||
}) | ||
.catch(err => done(err)) | ||
}) | ||
}) | ||
|
||
}) |