diff --git a/lib/routes/admin-api/strategy.test.js b/lib/routes/admin-api/strategy.test.js index 9b32fef8a9..f761c2f0ae 100644 --- a/lib/routes/admin-api/strategy.test.js +++ b/lib/routes/admin-api/strategy.test.js @@ -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); +}); diff --git a/test/fixtures/fake-strategies-store.js b/test/fixtures/fake-strategies-store.js index 82bbc1f86d..5f0d2be847 100644 --- a/test/fixtures/fake-strategies-store.js +++ b/test/fixtures/fake-strategies-store.js @@ -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),