mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-23 12:45:38 +00:00
fixes tests for the file body pr (#3940)
fixes tests for bruno-app and bruno-electron
This commit is contained in:
@@ -113,11 +113,9 @@ describe('curlToJson', () => {
|
||||
isDataBinary: true,
|
||||
data: [
|
||||
{
|
||||
name: 'file',
|
||||
value: ['/path/to/file'],
|
||||
enabled: true,
|
||||
filePath: '/path/to/file',
|
||||
contentType: 'application/json;charset=utf-8',
|
||||
type: 'file'
|
||||
selected: true
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
@@ -176,10 +176,10 @@ const setAuthHeaders = (axiosRequest, request, collectionRoot) => {
|
||||
return axiosRequest;
|
||||
};
|
||||
|
||||
const prepareRequest = async (item, collection, abortController) => {
|
||||
const prepareRequest = async (item, collection = {}, abortController) => {
|
||||
const request = item.draft ? item.draft.request : item.request;
|
||||
const collectionRoot = get(collection, 'root', {});
|
||||
const collectionPath = collection.pathname;
|
||||
const collectionPath = collection?.pathname;
|
||||
const headers = {};
|
||||
let contentTypeDefined = false;
|
||||
let url = request.url;
|
||||
@@ -191,7 +191,7 @@ const prepareRequest = async (item, collection, abortController) => {
|
||||
}
|
||||
});
|
||||
|
||||
const scriptFlow = collection.brunoConfig?.scripts?.flow ?? 'sandwich';
|
||||
const scriptFlow = collection?.brunoConfig?.scripts?.flow ?? 'sandwich';
|
||||
const requestTreePath = getTreePathFromCollectionToItem(collection, item);
|
||||
if (requestTreePath && requestTreePath.length > 0) {
|
||||
mergeHeaders(collection, request, requestTreePath);
|
||||
|
||||
@@ -7,15 +7,17 @@ describe('prepare-request: prepareRequest', () => {
|
||||
describe('Decomments request body', () => {
|
||||
it('If request body is valid JSON', async () => {
|
||||
const body = { mode: 'json', json: '{\n"test": "{{someVar}}" // comment\n}' };
|
||||
const expected = '{\n"test": "{{someVar}}" \n}';
|
||||
const result = prepareRequest({ request: { body } }, {});
|
||||
const expected = `{
|
||||
\"test\": \"{{someVar}}\"
|
||||
}`;
|
||||
const result = await prepareRequest({ request: { body }, collection: { pathname: '' } });
|
||||
expect(result.data).toEqual(expected);
|
||||
});
|
||||
|
||||
it('If request body is not valid JSON', async () => {
|
||||
const body = { mode: 'json', json: '{\n"test": {{someVar}} // comment\n}' };
|
||||
const expected = '{\n"test": {{someVar}} \n}';
|
||||
const result = prepareRequest({ request: { body } }, {});
|
||||
const result = await prepareRequest({ request: { body }, collection: { pathname: '' } });
|
||||
expect(result.data).toEqual(expected);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user