81 lines
2.2 KiB
JavaScript
81 lines
2.2 KiB
JavaScript
let urls = require('../config/api-url');
|
|
let codes = require('../routes/http-codes');
|
|
|
|
|
|
// Require the dev-dependencies
|
|
let chai = require('chai');
|
|
let chaiHttp = require('chai-http');
|
|
let server = require('../server');
|
|
|
|
// chai methods
|
|
require('chai').should();
|
|
|
|
chai.use(chaiHttp);
|
|
// Our parent block
|
|
describe('Wars', () => {
|
|
/*
|
|
* Test the /GET awardings
|
|
*/
|
|
describe('/GET wars', () => {
|
|
it('it should GET all wars', (done) => {
|
|
chai.request(server)
|
|
.get(urls.wars)
|
|
.end((err, res) => {
|
|
res.should.have.status(codes.success);
|
|
res.body.should.be.a('array');
|
|
res.body.length.should.be.eql(0);
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
/*
|
|
* Test the /POST awardings
|
|
*/
|
|
describe('/POST wars', () => {
|
|
it('it should not POST a war without auth-token provided', (done) => {
|
|
chai.request(server)
|
|
.post(urls.wars)
|
|
.send({})
|
|
.end((err, res) => {
|
|
res.should.have.status(codes.forbidden);
|
|
res.body.should.be.a('object');
|
|
res.body.should.have.property('success').eql(false);
|
|
res.body.should.have.property('message').eql('No token provided.');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
/*
|
|
* Test the /DELETE awardings
|
|
*/
|
|
describe('/DELETE wars', () => {
|
|
it('it should not accept DELETE method without id in url', (done) => {
|
|
chai.request(server)
|
|
.delete(urls.wars)
|
|
.send({})
|
|
.end((err, res) => {
|
|
res.should.have.status(codes.wrongmethod);
|
|
res.body.should.be.a('object');
|
|
res.body.should.have.property('error').property('message')
|
|
.eql('this method is not allowed at ' + urls.wars);
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('it should not DELETE an awarding without auth-token provided', (done) => {
|
|
chai.request(server)
|
|
.delete(urls.wars + '/someId')
|
|
.send({})
|
|
.end((err, res) => {
|
|
res.should.have.status(codes.forbidden);
|
|
res.body.should.be.a('object');
|
|
res.body.should.have.property('success').eql(false);
|
|
res.body.should.have.property('message').eql('No token provided.');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|