From e4407f39817b5ceecb50474c0002765f0a10b256 Mon Sep 17 00:00:00 2001 From: lohit Date: Thu, 22 Aug 2024 11:37:13 +0530 Subject: [PATCH] chore: updated testbench - primitive data types (#2888) * fix: getRequestVar shim, boolean values in vm * chore: updated testbench --- .../collection/scripting/js/data types.bru | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 packages/bruno-tests/collection/scripting/js/data types.bru diff --git a/packages/bruno-tests/collection/scripting/js/data types.bru b/packages/bruno-tests/collection/scripting/js/data types.bru new file mode 100644 index 000000000..a08c68b8f --- /dev/null +++ b/packages/bruno-tests/collection/scripting/js/data types.bru @@ -0,0 +1,54 @@ +meta { + name: data types + type: http + seq: 2 +} + +post { + url: {{host}}/api/echo/json + body: json + auth: none +} + +body:json { + { + "boolean": false, + "number": 1, + "string": "bruno", + "array": [1, 2, 3, 4, 5], + "object": { + "hello": "bruno" + }, + "null": null + } +} + +script:pre-request { + const reqBody = req.getBody(); + + bru.setVar("dataTypeVarTest", { + ...reqBody, + "undefined": undefined + }); +} + +tests { + test("data types check via bru var", function() { + let v = bru.getVar("dataTypeVarTest"); + v = { + ...v, + "undefined": undefined + }; + expect(v).to.eql({ + "boolean": false, + "number": 1, + "string": "bruno", + "array": [1, 2, 3, 4, 5], + "object": { + "hello": "bruno" + }, + "null": null, + "undefined": undefined + }) + }); +}