1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/test/strategyApiSpec.js
Anders Olsen Sandvik f01ef69d7e #108 Add eslint-config-spt and remove jshint (#111)
* #108 Add eslint-config-spt

* #108 Ignore bundle.js file

* #108 Change eslint ignore path to a glob file

* Remove jshint and follow more of eslint rules
2016-04-24 22:41:37 +02:00

69 lines
1.9 KiB
JavaScript

'use strict';
var specHelper = require('./specHelper');
var request = specHelper.request;
describe('The strategy api', function () {
beforeEach(function (done) {
specHelper.db.resetAndSetup()
.then(done.bind(null, null))
.catch(done);
});
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('cant get a strategy by name that dose not exist', function (done) {
request
.get('/strategies/mystrategy')
.expect('Content-Type', /json/)
.expect(404, 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);
});
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);
});
it('deletes a new strategy', function (done) {
request
.delete('/strategies/usersWithEmail')
.expect(200, done);
});
it('can\'t delete a strategy that dose not exist', function(done) {
request
.delete('/strategies/unknown')
.expect(404, done);
});
});