opt-cc/server/test/command.spec.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

let AwardingModel = require('../models/awarding');
let urls = require('../config/api-url');
let codes = require('../routes/http-codes');
2018-03-12 09:26:44 +01:00
// Require the dev-dependencies
let chai = require('chai');
let chaiHttp = require('chai-http');
let server = require('../server');
2018-03-12 12:35:19 +01:00
// chai methods
require('chai').should();
chai.use(chaiHttp);
2018-03-12 09:26:44 +01:00
// Our parent block
describe('Command', () => {
2018-03-12 09:26:44 +01:00
beforeEach((done) => { // Before each test we empty the database
AwardingModel.remove({}, (err) => {
done();
});
});
/*
* Test the /GET awardings
*/
describe('/POST command to create signature', () => {
it('it should not succeed without auth-token provided', (done) => {
chai.request(server)
2018-03-12 09:26:44 +01:00
.post(urls.cmdCreateSig + '/someId')
2018-02-26 09:04:27 +01:00
.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();
});
});
});
});