2014-11-25 15:28:08 +01:00
|
|
|
var specHelper = require('./specHelper');
|
|
|
|
|
|
|
|
describe('The strategy api', function () {
|
|
|
|
var request;
|
|
|
|
|
|
|
|
before(function () { request = specHelper.setupMockServer(); });
|
|
|
|
after(specHelper.tearDownMockServer);
|
|
|
|
|
|
|
|
it('gets all strategies', function (done) {
|
|
|
|
request
|
|
|
|
.get('/strategies')
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('gets a strategy by name', function (done) {
|
|
|
|
request
|
|
|
|
.get('/strategies/default')
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('creates a new strategy', function (done) {
|
|
|
|
request
|
|
|
|
.post('/strategies')
|
|
|
|
.send({name: 'myCustomStrategy', description: 'Best strategy ever.'})
|
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.expect(201, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('requires new strategies to have a name', function (done) {
|
|
|
|
request
|
|
|
|
.post('/strategies')
|
|
|
|
.send({name: ''})
|
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.expect(400, done);
|
|
|
|
});
|
|
|
|
|
2014-11-25 16:34:24 +01:00
|
|
|
it('refuses to create a strategy with an existing name', function (done) {
|
|
|
|
request
|
|
|
|
.post('/strategies')
|
|
|
|
.send({name: 'default'})
|
|
|
|
.set('Content-Type', 'application/json')
|
|
|
|
.expect(403, done);
|
|
|
|
});
|
|
|
|
|
2014-12-08 20:56:22 +01:00
|
|
|
it('deletes a new strategy', function (done) {
|
|
|
|
request
|
|
|
|
.delete('/strategies/deletable')
|
|
|
|
.expect(200, done);
|
|
|
|
});
|
2014-11-25 15:28:08 +01:00
|
|
|
});
|