mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-01 04:13:41 +01:00
feat(#1296): restructured toml json test setup
This commit is contained in:
parent
41d0698a87
commit
35b6f7bb0a
18
packages/bruno-toml/tests/index.spec.js
Normal file
18
packages/bruno-toml/tests/index.spec.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const jsonToToml = require('../src/jsonToToml');
|
||||||
|
const { describe } = require('@jest/globals');
|
||||||
|
|
||||||
|
const fixtures = ['methods/get', 'methods/delete'];
|
||||||
|
|
||||||
|
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');
|
||||||
|
it(`should convert json to toml`, () => {
|
||||||
|
expect(toml).toEqual(jsonToToml(json));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -0,0 +1,35 @@
|
|||||||
|
const jsonToToml = require('../../src/jsonToToml');
|
||||||
|
|
||||||
|
const json = {
|
||||||
|
meta: {
|
||||||
|
name: 'Get users',
|
||||||
|
type: 'http',
|
||||||
|
seq: '1'
|
||||||
|
},
|
||||||
|
http: {
|
||||||
|
method: 'get',
|
||||||
|
url: 'https://reqres.in/api/users'
|
||||||
|
},
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/json'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const toml = `[meta]
|
||||||
|
name = 'Get users'
|
||||||
|
type = 'http'
|
||||||
|
seq = '1'
|
||||||
|
|
||||||
|
[http]
|
||||||
|
method = 'get'
|
||||||
|
url = 'https://reqres.in/api/users'
|
||||||
|
|
||||||
|
[headers]
|
||||||
|
Accept = 'application/json'
|
||||||
|
`;
|
||||||
|
|
||||||
|
describe('jsonToToml - simple get', () => {
|
||||||
|
it('should parse the json file', () => {
|
||||||
|
expect(jsonToToml(json)).toEqual(toml);
|
||||||
|
});
|
||||||
|
});
|
@ -1,4 +1,3 @@
|
|||||||
const TOML = require('@iarna/toml');
|
|
||||||
const jsonToToml = require('../../src/jsonToToml');
|
const jsonToToml = require('../../src/jsonToToml');
|
||||||
|
|
||||||
const json = {
|
const json = {
|
||||||
@ -10,9 +9,6 @@ const json = {
|
|||||||
http: {
|
http: {
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: 'https://reqres.in/api/users'
|
url: 'https://reqres.in/api/users'
|
||||||
},
|
|
||||||
headers: {
|
|
||||||
Accept: 'application/json'
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -24,13 +20,10 @@ seq = '1'
|
|||||||
[http]
|
[http]
|
||||||
method = 'get'
|
method = 'get'
|
||||||
url = 'https://reqres.in/api/users'
|
url = 'https://reqres.in/api/users'
|
||||||
|
|
||||||
[headers]
|
|
||||||
Accept = 'application/json'
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
describe('jsonToToml - simple get', () => {
|
describe('jsonToToml - simple get', () => {
|
||||||
it('should parse the json file', () => {
|
it('should parse the json', () => {
|
||||||
expect(jsonToToml(json)).toEqual(toml);
|
expect(jsonToToml(json)).toEqual(toml);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
11
packages/bruno-toml/tests/methods/delete/request.json
Normal file
11
packages/bruno-toml/tests/methods/delete/request.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"name": "Delete User",
|
||||||
|
"type": "http",
|
||||||
|
"seq": 1
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"method": "DELETE",
|
||||||
|
"url": "https://reqres.in/api/users/2"
|
||||||
|
}
|
||||||
|
}
|
8
packages/bruno-toml/tests/methods/delete/request.toml
Normal file
8
packages/bruno-toml/tests/methods/delete/request.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[meta]
|
||||||
|
name = 'Delete User'
|
||||||
|
type = 'http'
|
||||||
|
seq = 1
|
||||||
|
|
||||||
|
[http]
|
||||||
|
method = 'DELETE'
|
||||||
|
url = 'https://reqres.in/api/users/2'
|
11
packages/bruno-toml/tests/methods/get/request.json
Normal file
11
packages/bruno-toml/tests/methods/get/request.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"meta": {
|
||||||
|
"name": "Get users",
|
||||||
|
"type": "http",
|
||||||
|
"seq": 1
|
||||||
|
},
|
||||||
|
"http": {
|
||||||
|
"method": "GET",
|
||||||
|
"url": "https://reqres.in/api/users"
|
||||||
|
}
|
||||||
|
}
|
8
packages/bruno-toml/tests/methods/get/request.toml
Normal file
8
packages/bruno-toml/tests/methods/get/request.toml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
[meta]
|
||||||
|
name = 'Get users'
|
||||||
|
type = 'http'
|
||||||
|
seq = 1
|
||||||
|
|
||||||
|
[http]
|
||||||
|
method = 'GET'
|
||||||
|
url = 'https://reqres.in/api/users'
|
Loading…
Reference in New Issue
Block a user