Fix tests

This commit is contained in:
Gregory Schier 2018-01-29 14:46:10 +08:00
parent 8be0f36c71
commit 5cd80bbb2c
2 changed files with 5 additions and 1 deletions

View File

@ -22,6 +22,7 @@ describe('init()', () => {
expect(Object.keys(result)).toEqual(['request']); expect(Object.keys(result)).toEqual(['request']);
expect(Object.keys(result.request).sort()).toEqual([ expect(Object.keys(result.request).sort()).toEqual([
'addHeader', 'addHeader',
'getBodyText',
'getEnvironment', 'getEnvironment',
'getEnvironmentVariable', 'getEnvironmentVariable',
'getHeader', 'getHeader',
@ -32,6 +33,7 @@ describe('init()', () => {
'getUrl', 'getUrl',
'hasHeader', 'hasHeader',
'removeHeader', 'removeHeader',
'setBodyText',
'setCookie', 'setCookie',
'setHeader', 'setHeader',
'settingDisableRenderRequestBody', 'settingDisableRenderRequestBody',
@ -55,6 +57,7 @@ describe('request.*', () => {
_id: 'req_1', _id: 'req_1',
parentId: 'wrk_1', parentId: 'wrk_1',
name: 'My Request', name: 'My Request',
body: {text: 'body'},
headers: [ headers: [
{name: 'hello', value: 'world'}, {name: 'hello', value: 'world'},
{name: 'Content-Type', value: 'application/json'} {name: 'Content-Type', value: 'application/json'}
@ -68,6 +71,7 @@ describe('request.*', () => {
expect(result.request.getName()).toBe('My Request'); expect(result.request.getName()).toBe('My Request');
expect(result.request.getUrl()).toBe(''); expect(result.request.getUrl()).toBe('');
expect(result.request.getMethod()).toBe('GET'); expect(result.request.getMethod()).toBe('GET');
expect(result.request.getBodyText()).toBe('body');
}); });
it('works for headers', async () => { it('works for headers', async () => {

View File

@ -16,7 +16,7 @@ export function init (
return renderedRequest._id; return renderedRequest._id;
}, },
getBodyText (): string { getBodyText (): string {
return renderedRequest.body.text; return renderedRequest.body.text || '';
}, },
getName (): string { getName (): string {
return renderedRequest.name; return renderedRequest.name;