2024-06-19 12:48:36 +02:00
|
|
|
const { describe, it, expect } = require('@jest/globals');
|
|
|
|
|
|
|
|
const prepareRequest = require('../../src/ipc/network/prepare-request');
|
|
|
|
|
|
|
|
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}' };
|
2024-08-27 10:42:56 +02:00
|
|
|
const expected = '{\n"test": "{{someVar}}" \n}';
|
2024-07-01 09:22:56 +02:00
|
|
|
const result = prepareRequest({ request: { body } }, {});
|
2024-06-19 12:48:36 +02:00
|
|
|
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}';
|
2024-07-01 09:22:56 +02:00
|
|
|
const result = prepareRequest({ request: { body } }, {});
|
2024-06-19 12:48:36 +02:00
|
|
|
expect(result.data).toEqual(expected);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|