2023-02-06 20:48:18 +01:00
|
|
|
/**
|
|
|
|
* This test file is used to test the text parser.
|
|
|
|
*/
|
2023-09-21 21:12:48 +02:00
|
|
|
const parser = require('../src/bruToJson');
|
2023-02-06 20:48:18 +01:00
|
|
|
|
2023-09-21 21:12:48 +02:00
|
|
|
describe('script parser', () => {
|
|
|
|
it('should parse request script', () => {
|
2023-02-06 20:48:18 +01:00
|
|
|
const input = `
|
2023-02-07 00:09:23 +01:00
|
|
|
script:pre-request {
|
2023-02-06 20:48:18 +01:00
|
|
|
$req.setHeader('Content-Type', 'application/json');
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const output = parser(input);
|
|
|
|
const expected = {
|
2023-09-21 21:12:48 +02:00
|
|
|
script: {
|
|
|
|
req: "$req.setHeader('Content-Type', 'application/json');"
|
2023-02-06 20:48:18 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
expect(output).toEqual(expected);
|
|
|
|
});
|
|
|
|
|
2023-09-21 21:12:48 +02:00
|
|
|
it('should parse response script', () => {
|
2023-02-06 20:48:18 +01:00
|
|
|
const input = `
|
2023-02-07 00:09:23 +01:00
|
|
|
script:post-response {
|
2023-02-06 20:48:18 +01:00
|
|
|
expect(response.status).to.equal(200);
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const output = parser(input);
|
|
|
|
const expected = {
|
2023-09-21 21:12:48 +02:00
|
|
|
script: {
|
|
|
|
res: 'expect(response.status).to.equal(200);'
|
2023-02-06 20:48:18 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
expect(output).toEqual(expected);
|
|
|
|
});
|
|
|
|
});
|