forked from extern/bruno
39 lines
798 B
JavaScript
39 lines
798 B
JavaScript
/**
|
|
* This test file is used to test the text parser.
|
|
*/
|
|
const parser = require("../src/bruToJson");
|
|
|
|
describe("script parser", () => {
|
|
it("should parse request script", () => {
|
|
const input = `
|
|
script:req {
|
|
$req.setHeader('Content-Type', 'application/json');
|
|
}
|
|
`;
|
|
|
|
const output = parser(input);
|
|
const expected = {
|
|
"script": {
|
|
"req": "$req.setHeader('Content-Type', 'application/json');"
|
|
}
|
|
};
|
|
expect(output).toEqual(expected);
|
|
});
|
|
|
|
it("should parse response script", () => {
|
|
const input = `
|
|
script:res {
|
|
expect(response.status).to.equal(200);
|
|
}
|
|
`;
|
|
|
|
const output = parser(input);
|
|
const expected = {
|
|
"script": {
|
|
"res": "expect(response.status).to.equal(200);"
|
|
}
|
|
};
|
|
expect(output).toEqual(expected);
|
|
});
|
|
});
|