1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-25 00:07:47 +01:00

add editable tests

This commit is contained in:
sveisvei 2017-06-29 08:42:03 +02:00 committed by Ivar Conradi Østhus
parent a9b783443b
commit b137cf0eaa
2 changed files with 44 additions and 1 deletions

View File

@ -123,3 +123,46 @@ test('validate format when updating strategy', t => {
.send({})
.expect(400);
});
test('editable=false will stop delete request', t => {
t.plan(0);
const name = 'default';
const { request, base } = getSetup();
return request.delete(`${base}/api/admin/strategies/${name}`).expect(500);
});
test('editable=false will stop edit request', t => {
t.plan(0);
const name = 'default';
const { request, base } = getSetup();
return request
.put(`${base}/api/admin/strategies/${name}`)
.send({ name, parameters: [] })
.expect(500);
});
test('editable=true will allow delete request', t => {
t.plan(0);
const name = 'deleteStrat';
const { request, base, strategyStore } = getSetup();
strategyStore.addStrategy({ name, parameters: [] });
return request
.delete(`${base}/api/admin/strategies/${name}`)
.send({})
.expect(200);
});
test('editable=true will allow edit request', t => {
t.plan(0);
const name = 'editStrat';
const { request, base, strategyStore } = getSetup();
strategyStore.addStrategy({ name, parameters: [] });
return request
.put(`${base}/api/admin/strategies/${name}`)
.send({ name, parameters: [] })
.expect(200);
});

View File

@ -3,7 +3,7 @@
const NotFoundError = require('../../lib/error/notfound-error');
module.exports = () => {
const _strategies = [{ name: 'default', parameters: {} }];
const _strategies = [{ name: 'default', editable: false, parameters: {} }];
return {
getStrategies: () => Promise.resolve(_strategies),