diff --git a/app/src/renderer/lcdClient.js b/app/src/renderer/lcdClient.js index ae4b76654c..0a06862af5 100644 --- a/app/src/renderer/lcdClient.js +++ b/app/src/renderer/lcdClient.js @@ -19,6 +19,11 @@ function argReq (method, path) { if (Array.isArray(args)) { args = args.join('/') } + if (method === 'DELETE') { + data = { + data + } + } return await this.request(method, `${path}/${args}`, data) } } @@ -57,6 +62,7 @@ Object.assign(Client.prototype, { listKeys: req('GET', '/keys'), getKey: argReq('GET', '/keys'), updateKey: argReq('PUT', '/keys'), + // axios handles DELETE requests different then other requests, we have to but the body in a config object with the prop data deleteKey: argReq('DELETE', '/keys'), recoverKey: req('POST', '/keys/recover'), diff --git a/test/unit/specs/lcdClient.spec.js b/test/unit/specs/lcdClient.spec.js index 775db24a2e..8e562662cb 100644 --- a/test/unit/specs/lcdClient.spec.js +++ b/test/unit/specs/lcdClient.spec.js @@ -97,6 +97,17 @@ describe('LCD Client', () => { ]) }) + it('delete requests have the correct format for data', async () => { + axios.delete = (path, config) => { + expect(config).toEqual({data: {password: 'abc'}}) + return Promise.resolve({data: { + foo: 'bar' + }}) + } + + await client.deleteKey('test', {password: 'abc'}) + }) + it('does not throw error for empty results', async () => { axios.get = jest.fn() .mockReturnValueOnce(Promise.reject({