2023-01-14 15:46:09 +01:00
|
|
|
const fs = require('fs');
|
|
|
|
const path = require('path');
|
|
|
|
|
|
|
|
const {
|
2023-01-15 20:19:06 +01:00
|
|
|
jsonToBru
|
2023-01-14 15:46:09 +01:00
|
|
|
} = require('../src');
|
|
|
|
|
|
|
|
describe('bruToJson', () => {
|
2023-01-15 20:19:06 +01:00
|
|
|
it('should convert json file into .bru file', () => {
|
|
|
|
const request = {
|
2023-01-14 15:46:09 +01:00
|
|
|
"ver": "1.0",
|
|
|
|
"type": "http-request",
|
|
|
|
"name": "Send Bulk SMS",
|
|
|
|
"method": "GET",
|
|
|
|
"url": "https://api.textlocal.in/bulk_json?apiKey=secret=&numbers=919988776655&message=hello&sender=600010",
|
|
|
|
"params": [
|
|
|
|
{
|
|
|
|
"enabled": "1",
|
|
|
|
"key": "apiKey",
|
|
|
|
"value": "secret"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enabled": "1",
|
|
|
|
"key": "numbers",
|
|
|
|
"value": "998877665"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enabled": "1",
|
|
|
|
"key": "message",
|
|
|
|
"value": "hello"
|
|
|
|
}
|
2023-01-14 15:51:54 +01:00
|
|
|
],
|
|
|
|
"headers": [
|
|
|
|
{
|
|
|
|
"enabled": "1",
|
|
|
|
"key": "content-type",
|
|
|
|
"value": "application/json"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enabled": "1",
|
|
|
|
"key": "accept-language",
|
|
|
|
"value": "en-US,en;q=0.9,hi;q=0.8"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enabled": "0",
|
|
|
|
"key": "transaction-id",
|
|
|
|
"value": "{{transactionId}}"
|
|
|
|
}
|
2023-01-14 20:15:01 +01:00
|
|
|
],
|
2023-01-14 23:21:48 +01:00
|
|
|
"body": {
|
2023-01-15 20:19:06 +01:00
|
|
|
"mode": "json",
|
2023-01-14 23:21:48 +01:00
|
|
|
"json": '{"apikey":"secret","numbers":"+91998877665"}',
|
|
|
|
"graphql": {
|
2023-01-15 20:19:06 +01:00
|
|
|
"query": "{\n launchesPast {\n launch_success\n }\n}"
|
2023-01-14 23:33:52 +01:00
|
|
|
},
|
2023-01-15 20:19:06 +01:00
|
|
|
"text": "Hello, there. You must be from the past",
|
|
|
|
"xml": "<body>back to the ice age</body>",
|
2023-01-15 18:12:56 +01:00
|
|
|
"formUrlEncoded": [
|
|
|
|
{
|
|
|
|
"enabled": "1",
|
|
|
|
"key": "username",
|
|
|
|
"value": "john"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enabled": "0",
|
|
|
|
"key": "password",
|
|
|
|
"value": "{{password}}"
|
|
|
|
}
|
2023-01-15 18:32:59 +01:00
|
|
|
],
|
|
|
|
"multipartForm": [
|
|
|
|
{
|
|
|
|
"enabled": "1",
|
|
|
|
"key": "username",
|
|
|
|
"value": "nash"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"enabled": "0",
|
|
|
|
"key": "password",
|
|
|
|
"value": "governingdynamics"
|
|
|
|
}
|
2023-01-15 18:12:56 +01:00
|
|
|
]
|
2023-01-14 23:21:48 +01:00
|
|
|
}
|
2023-01-15 20:19:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const expectedBruFile = fs.readFileSync(path.join(__dirname, 'fixtures', 'request.bru'), 'utf8');
|
|
|
|
const actualBruFile = jsonToBru(request);
|
|
|
|
|
|
|
|
expect(expectedBruFile).toEqual(actualBruFile);
|
2023-01-14 15:46:09 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|