insomnia-plugin-response
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -103,5 +103,3 @@ const tag = require('..').templateTags[0]; | ||
} catch (err) { | ||
expect(err.message).toContain( | ||
'Invalid JSON: Unexpected end of JSON input' | ||
); | ||
expect(err.message).toContain('Invalid JSON: Unexpected end of JSON input'); | ||
} | ||
@@ -175,5 +173,3 @@ }); | ||
} catch (err) { | ||
expect(err.message).toContain( | ||
'Returned more than one result: $.array.*' | ||
); | ||
expect(err.message).toContain('Returned more than one result: $.array.*'); | ||
} | ||
@@ -254,8 +250,3 @@ }); | ||
const context = _genTestContext(requests, responses); | ||
const result = await tag.run( | ||
context, | ||
'body', | ||
'req_1', | ||
'substring(/foo/bar, 7)' | ||
); | ||
const result = await tag.run(context, 'body', 'req_1', 'substring(/foo/bar, 7)'); | ||
@@ -377,14 +368,8 @@ expect(result).toBe('World!'); | ||
expect(await tag.run(context, 'header', 'req_1', 'content-type')).toBe( | ||
expect(await tag.run(context, 'header', 'req_1', 'content-type')).toBe('application/json'); | ||
expect(await tag.run(context, 'header', 'req_1', 'Content-Type')).toBe('application/json'); | ||
expect(await tag.run(context, 'header', 'req_1', 'CONTENT-type')).toBe('application/json'); | ||
expect(await tag.run(context, 'header', 'req_1', 'CONTENT-type ')).toBe( | ||
'application/json' | ||
); | ||
expect(await tag.run(context, 'header', 'req_1', 'Content-Type')).toBe( | ||
'application/json' | ||
); | ||
expect(await tag.run(context, 'header', 'req_1', 'CONTENT-type')).toBe( | ||
'application/json' | ||
); | ||
expect( | ||
await tag.run(context, 'header', 'req_1', 'CONTENT-type ') | ||
).toBe('application/json'); | ||
}); | ||
@@ -391,0 +376,0 @@ |
18
index.js
@@ -69,5 +69,3 @@ const jq = require('jsonpath'); | ||
const response = await context.util.models.response.getLatestForRequestId( | ||
id | ||
); | ||
const response = await context.util.models.response.getLatestForRequestId(id); | ||
@@ -91,6 +89,3 @@ if (!response) { | ||
} else if (field === 'raw') { | ||
const bodyBuffer = context.util.models.response.getBodyBuffer( | ||
response, | ||
'' | ||
); | ||
const bodyBuffer = context.util.models.response.getBodyBuffer(response, ''); | ||
const match = response.contentType.match(/charset=([\w-]+)/); | ||
@@ -107,6 +102,3 @@ const charset = match && match.length >= 2 ? match[1] : 'utf-8'; | ||
} else if (field === 'body') { | ||
const bodyBuffer = context.util.models.response.getBodyBuffer( | ||
response, | ||
'' | ||
); | ||
const bodyBuffer = context.util.models.response.getBodyBuffer(response, ''); | ||
const match = response.contentType.match(/charset=([\w-]+)/); | ||
@@ -186,5 +178,3 @@ const charset = match && match.length >= 2 ? match[1] : 'utf-8'; | ||
const names = headers.map(c => `"${c.name}"`).join(',\n\t'); | ||
throw new Error( | ||
`No header with name "${name}".\nChoices are [\n\t${names}\n]` | ||
); | ||
throw new Error(`No header with name "${name}".\nChoices are [\n\t${names}\n]`); | ||
} | ||
@@ -191,0 +181,0 @@ |
{ | ||
"name": "insomnia-plugin-response", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"author": "Gregory Schier <gschier1990@gmail.com>", | ||
@@ -20,6 +20,6 @@ "description": "Insomnia response template tag", | ||
"iconv-lite": "^0.4.19", | ||
"insomnia-xpath": "^1.0.7", | ||
"insomnia-xpath": "^1.0.8", | ||
"jsonpath": "^1.0.0" | ||
}, | ||
"gitHead": "2805a5f9fed4a804b9615ec82463b90f865c38ff" | ||
"gitHead": "d0652a5b918564e19980afe6905027f7c8fda522" | ||
} |
25194
534
Updatedinsomnia-xpath@^1.0.8