Files
bruno/packages/bruno-tests/collection/string interpolation/objects-arrays interpolation.bru
lohit e34e2ec1f1 feat: support object and array interpolation in bruno-common interpolate fn (#4519)
---------
Co-authored-by: Pooja Belaramani <pooja@usebruno.com>
Co-authored-by: lohit jiddimani <lohitjiddimani@lohits-MacBook-Air.local>
Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
2025-04-18 00:47:02 +05:30

82 lines
1.4 KiB
Plaintext

meta {
name: objects/arrays interpolation
type: http
seq: 5
}
post {
url: https://echo.usebruno.com
body: json
auth: none
}
body:json {
{
"undefined": "{{obj.undefined}}",
"null": {{obj.null}},
"number": {{obj.number}},
"boolean": {{obj.boolean}},
"array": {{arr}},
"array[0]": {{arr[0]}},
"object": {{obj}},
"object.foo": {{obj.foo}},
"object.foo.bar": {{obj.foo.bar}},
"object.foo.bar.baz": {{obj.foo.bar.baz}}
}
}
script:pre-request {
bru.setVar("arr", [1,2,3,4,5]);
bru.setVar("obj", {
"null": null,
"number": 1,
"boolean": true,
"foo": {
"bar": {
"baz": 1
}
}
});
}
tests {
test("should interpolate arrays and objects in request payload body", () => {
const resBody = res.getBody();
const expectedOutput = {
"undefined": "{{obj.undefined}}",
"null": null,
"number": 1,
"boolean": true,
"array": [
1,
2,
3,
4,
5
],
"array[0]": 1,
"object": {
"null": null,
"number": 1,
"boolean": true,
"foo": {
"bar": {
"baz": 1
}
}
},
"object.foo": {
"bar": {
"baz": 1
}
},
"object.foo.bar": {
"baz": 1
},
"object.foo.bar.baz": 1
};
expect(resBody).to.be.eql(expectedOutput);
})
}