From 5cd80bbb2cf4f3e2a06ad89438076f313770f19e Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 29 Jan 2018 14:46:10 +0800 Subject: [PATCH] Fix tests --- .../app/plugins/context/__tests__/request.test.js | 4 ++++ packages/insomnia-app/app/plugins/context/request.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/insomnia-app/app/plugins/context/__tests__/request.test.js b/packages/insomnia-app/app/plugins/context/__tests__/request.test.js index af11990c2..9ee7c0415 100644 --- a/packages/insomnia-app/app/plugins/context/__tests__/request.test.js +++ b/packages/insomnia-app/app/plugins/context/__tests__/request.test.js @@ -22,6 +22,7 @@ describe('init()', () => { expect(Object.keys(result)).toEqual(['request']); expect(Object.keys(result.request).sort()).toEqual([ 'addHeader', + 'getBodyText', 'getEnvironment', 'getEnvironmentVariable', 'getHeader', @@ -32,6 +33,7 @@ describe('init()', () => { 'getUrl', 'hasHeader', 'removeHeader', + 'setBodyText', 'setCookie', 'setHeader', 'settingDisableRenderRequestBody', @@ -55,6 +57,7 @@ describe('request.*', () => { _id: 'req_1', parentId: 'wrk_1', name: 'My Request', + body: {text: 'body'}, headers: [ {name: 'hello', value: 'world'}, {name: 'Content-Type', value: 'application/json'} @@ -68,6 +71,7 @@ describe('request.*', () => { expect(result.request.getName()).toBe('My Request'); expect(result.request.getUrl()).toBe(''); expect(result.request.getMethod()).toBe('GET'); + expect(result.request.getBodyText()).toBe('body'); }); it('works for headers', async () => { diff --git a/packages/insomnia-app/app/plugins/context/request.js b/packages/insomnia-app/app/plugins/context/request.js index 1c68b4df0..dc4a71692 100644 --- a/packages/insomnia-app/app/plugins/context/request.js +++ b/packages/insomnia-app/app/plugins/context/request.js @@ -16,7 +16,7 @@ export function init ( return renderedRequest._id; }, getBodyText (): string { - return renderedRequest.body.text; + return renderedRequest.body.text || ''; }, getName (): string { return renderedRequest.name;