Skip to content

Commit

Permalink
More test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
FabioBeneditto committed Feb 28, 2022
1 parent f1288e9 commit 394e88c
Showing 1 changed file with 45 additions and 5 deletions.
50 changes: 45 additions & 5 deletions test/index.js
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))
})
})

})

0 comments on commit 394e88c

Please sign in to comment.