Skip to content

Commit

Permalink
test: fix the framing of test cases description statments
Browse files Browse the repository at this point in the history
  • Loading branch information
vedkribhu committed Oct 11, 2023
1 parent 4acceff commit 1035516
Showing 1 changed file with 106 additions and 47 deletions.
153 changes: 106 additions & 47 deletions test/integration/sandbox-libraries/pm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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'
}
Expand Down Expand Up @@ -883,7 +942,7 @@ describe('sandbox library - pm api', function () {
});

it(`should have path as correct path for a request inside collection when printed from
test-request script of request`, function () {
tests script of request`, function () {
sinon.assert.calledWith(testrun.done.getCall(0), null);

const collPreConsole = testrun.console.getCall(7).args.slice(2);
Expand Down

0 comments on commit 1035516

Please sign in to comment.