From e9da9afa475dfb029ab729faed30afee12de369b Mon Sep 17 00:00:00 2001 From: Vedanta Krishna Date: Wed, 11 Oct 2023 17:09:04 +0530 Subject: [PATCH] test: fix the framing of test cases description statments --- test/integration/sandbox-libraries/pm.test.js | 151 ++++++++++++------ 1 file changed, 105 insertions(+), 46 deletions(-) diff --git a/test/integration/sandbox-libraries/pm.test.js b/test/integration/sandbox-libraries/pm.test.js index eb05bd63d..d1c76655d 100644 --- a/test/integration/sandbox-libraries/pm.test.js +++ b/test/integration/sandbox-libraries/pm.test.js @@ -581,65 +581,124 @@ describe('sandbox library - pm api', function () { describe('pm.info properties', function () { describe('pm.info.requestPath', function () { - it('should have path as empty array for un-saved requests', function (done) { - this.run({ - collection: { - item: [{ - event: [ - { - listen: 'prerequest', - script: { - exec: [ - 'console.log("path", pm.info.requestPath)' + describe('for requests without valid name property', function () { + it('should have path as empty array when printed from pre-request script', function (done) { + this.run({ + collection: { + item: [{ + event: [ + { + listen: 'prerequest', + script: { + exec: [ + 'console.log("path", pm.info.requestPath)' + ], + type: 'text/javascript' + } + } + ], + request: { + auth: { + type: 'noauth' + }, + method: 'GET', + header: [ + { + key: 'fs', + value: '', + type: 'text' + } + ], + url: { + raw: 'postman-echo.com/get', + host: [ + 'postman-echo', + 'com' ], - type: 'text/javascript' + path: [ + 'get' + ] } - } - ], - request: { - auth: { - type: 'noauth' }, - method: 'GET', - header: [ + response: [] + }] + } + } + , function (_err, results) { + testrun = results; + expect(testrun).to.be.ok; + sinon.assert.calledOnce(testrun.start); + sinon.assert.calledOnce(testrun.done); + sinon.assert.calledWith(testrun.done.getCall(0), null); + + const collPreConsole = testrun.console.getCall(0).args.slice(2); + + expect(collPreConsole).to.deep.include.ordered.members(['path', + []]); + done(); + }); + }); + + it('should have path as empty array when printed from tests script', function (done) { + this.run({ + collection: { + item: [{ + event: [ { - key: 'fs', - value: '', - type: 'text' + listen: 'test', + script: { + exec: [ + 'console.log("path", pm.info.requestPath)' + ], + type: 'text/javascript' + } } ], - url: { - raw: 'postman-echo.com/get', - host: [ - 'postman-echo', - 'com' + request: { + auth: { + type: 'noauth' + }, + method: 'GET', + header: [ + { + key: 'fs', + value: '', + type: 'text' + } ], - path: [ - 'get' - ] - } - }, - response: [] - }] + url: { + raw: 'postman-echo.com/get', + host: [ + 'postman-echo', + 'com' + ], + path: [ + 'get' + ] + } + }, + response: [] + }] + } } - } - , function (_err, results) { - testrun = results; - expect(testrun).to.be.ok; - sinon.assert.calledOnce(testrun.start); - sinon.assert.calledOnce(testrun.done); - sinon.assert.calledWith(testrun.done.getCall(0), null); + , function (_err, results) { + testrun = results; + expect(testrun).to.be.ok; + sinon.assert.calledOnce(testrun.start); + sinon.assert.calledOnce(testrun.done); + sinon.assert.calledWith(testrun.done.getCall(0), null); - const collPreConsole = testrun.console.getCall(0).args.slice(2); + const collPreConsole = testrun.console.getCall(0).args.slice(2); - expect(collPreConsole).to.deep.include.ordered.members(['path', - []]); - done(); + expect(collPreConsole).to.deep.include.ordered.members(['path', + []]); + done(); + }); }); }); - describe('saved request cases', function () { + describe('for request\'s with valid name properties', function () { before(function (done) { this.run({ collection: { @@ -723,7 +782,7 @@ describe('sandbox library - pm api', function () { listen: 'prerequest', script: { exec: [ - 'console.log("path", pm.info.requestPath)' + 'console.log("request pre", pm.info.requestPath)' ], type: 'text/javascript' }