1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-28 00:06:53 +01:00
unleash.unleash/packages/unleash-api/test/e2e/strategyApiSpec.js

70 lines
1.9 KiB
JavaScript
Raw Normal View History

'use strict';
2016-10-26 10:43:11 +02:00
2016-06-18 21:53:18 +02:00
const specHelper = require('./specHelper');
const request = specHelper.request;
2016-06-18 21:53:18 +02:00
describe('The strategy api', () => {
beforeEach(done => {
specHelper.db.resetAndSetup()
.then(done.bind(null, null))
.catch(done);
});
2016-06-18 21:53:18 +02:00
it('gets all strategies', done => {
request
.get('/strategies')
.expect('Content-Type', /json/)
.expect(200, done);
});
2016-06-18 21:53:18 +02:00
it('gets a strategy by name', done => {
request
.get('/strategies/default')
.expect('Content-Type', /json/)
.expect(200, done);
});
2016-06-18 21:53:18 +02:00
it('cant get a strategy by name that dose not exist', done => {
request
.get('/strategies/mystrategy')
.expect('Content-Type', /json/)
.expect(404, done);
});
2016-06-18 21:53:18 +02:00
it('creates a new strategy', done => {
request
.post('/strategies')
.send({ name: 'myCustomStrategy', description: 'Best strategy ever.' })
.set('Content-Type', 'application/json')
.expect(201, done);
});
2016-06-18 21:53:18 +02:00
it('requires new strategies to have a name', done => {
request
.post('/strategies')
.send({ name: '' })
.set('Content-Type', 'application/json')
.expect(400, done);
});
2016-06-18 21:53:18 +02:00
it('refuses to create a strategy with an existing name', done => {
request
.post('/strategies')
.send({ name: 'default' })
.set('Content-Type', 'application/json')
.expect(403, done);
});
2016-06-18 21:53:18 +02:00
it('deletes a new strategy', done => {
request
.delete('/strategies/usersWithEmail')
.expect(200, done);
});
2016-06-18 21:53:18 +02:00
it('can\'t delete a strategy that dose not exist', done => {
request
.delete('/strategies/unknown')
.expect(404, done);
});
});