mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-26 14:15:52 +00:00
--------- 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>
82 lines
1.4 KiB
Plaintext
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);
|
|
})
|
|
}
|