2023-02-03 00:09:45 +01:00
|
|
|
const parser = require("../src/index");
|
|
|
|
|
|
|
|
describe("parser", () => {
|
2023-02-03 16:38:40 +01:00
|
|
|
it("should parse the bru file", () => {
|
2023-02-03 03:31:44 +01:00
|
|
|
const input = `
|
|
|
|
headers {
|
|
|
|
hello: world
|
|
|
|
foo: bar
|
2023-02-03 16:38:40 +01:00
|
|
|
}
|
2023-02-03 03:31:44 +01:00
|
|
|
|
|
|
|
script {
|
|
|
|
function onResponse(request, response) {
|
|
|
|
expect(response.status).to.equal(200);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
2023-02-03 00:09:45 +01:00
|
|
|
|
2023-02-03 03:31:44 +01:00
|
|
|
const output = parser(input);
|
2023-02-03 16:38:40 +01:00
|
|
|
const expected = {
|
|
|
|
"headers": [
|
|
|
|
{
|
|
|
|
"name": "hello",
|
|
|
|
"value": "world",
|
|
|
|
"enabled": true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "foo",
|
|
|
|
"value": "bar",
|
|
|
|
"enabled": true
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"script": " function onResponse(request, response) {\n expect(response.status).to.equal(200);\n }"
|
|
|
|
}
|
|
|
|
expect(output).toEqual(expected);
|
2023-02-03 00:09:45 +01:00
|
|
|
});
|
|
|
|
});
|