2023-12-30 12:43:15 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
const jsonToToml = require('../src/jsonToToml');
|
2023-12-30 14:39:17 +01:00
|
|
|
const tomlToJson = require('../src/tomlToJson');
|
2023-12-30 12:43:15 +01:00
|
|
|
|
2023-12-30 15:59:31 +01:00
|
|
|
const fixtures = [
|
|
|
|
'methods/get',
|
|
|
|
'methods/delete',
|
2023-12-30 16:57:15 +01:00
|
|
|
'headers/simple-header',
|
2023-12-30 15:59:31 +01:00
|
|
|
'headers/empty-header',
|
|
|
|
'headers/spaces-in-header',
|
|
|
|
'headers/unicode-in-header',
|
2023-12-30 16:57:15 +01:00
|
|
|
'headers/disabled-header',
|
|
|
|
'headers/dotted-header',
|
2023-12-30 17:23:37 +01:00
|
|
|
'headers/duplicate-header',
|
2023-12-30 22:22:41 +01:00
|
|
|
'headers/reserved-header',
|
|
|
|
'scripts/pre-request',
|
|
|
|
'scripts/post-response',
|
|
|
|
'scripts/tests'
|
2023-12-30 15:59:31 +01:00
|
|
|
];
|
2023-12-30 12:43:15 +01:00
|
|
|
|
|
|
|
describe('bruno toml', () => {
|
|
|
|
fixtures.forEach((fixture) => {
|
|
|
|
describe(fixture, () => {
|
|
|
|
const json = require(`./${fixture}/request.json`);
|
|
|
|
const toml = fs.readFileSync(path.join(__dirname, fixture, 'request.toml'), 'utf8');
|
2023-12-30 14:39:17 +01:00
|
|
|
|
|
|
|
if (process.env.DEBUG === 'true') {
|
|
|
|
console.log(`DEBUG: Running ${fixture} tests`);
|
|
|
|
console.log('json', JSON.stringify(json, null, 2));
|
|
|
|
console.log('toml', toml);
|
|
|
|
console.log('jsonToToml', jsonToToml(json));
|
|
|
|
console.log('tomlToJson', JSON.stringify(tomlToJson(toml), null, 2));
|
|
|
|
}
|
|
|
|
|
2023-12-30 12:43:15 +01:00
|
|
|
it(`should convert json to toml`, () => {
|
|
|
|
expect(toml).toEqual(jsonToToml(json));
|
|
|
|
});
|
2023-12-30 14:39:17 +01:00
|
|
|
|
|
|
|
it(`should convert toml to json`, () => {
|
2023-12-30 22:22:41 +01:00
|
|
|
expect(json).toEqual(tomlToJson(toml));
|
2023-12-30 14:39:17 +01:00
|
|
|
});
|
2023-12-30 12:43:15 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|