From 1b3e2e887046f96e51600ea01d12dede12cbe519 Mon Sep 17 00:00:00 2001 From: Jatin Parekh Date: Mon, 11 Sep 2023 16:39:27 +0530 Subject: [PATCH 1/3] Allow description as a property in PostmanVariable to be updated (#1332) --- lib/collection/variable.js | 1 + test/unit/variable-list.test.js | 22 ++++++++++++++++++++++ test/unit/variable.test.js | 25 +++++++++++++++++++------ 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/lib/collection/variable.js b/lib/collection/variable.js index da0928128..cac0a041f 100644 --- a/lib/collection/variable.js +++ b/lib/collection/variable.js @@ -207,6 +207,7 @@ _.assign(Variable.prototype, /** @lends Variable.prototype */ { _.has(options, 'value') && this.set(options.value); _.has(options, 'system') && (this.system = options.system); _.has(options, 'disabled') && (this.disabled = options.disabled); + _.has(options, 'description') && (this.describe(options.description)); } }); diff --git a/test/unit/variable-list.test.js b/test/unit/variable-list.test.js index d782fcc89..7532a2b5c 100644 --- a/test/unit/variable-list.test.js +++ b/test/unit/variable-list.test.js @@ -255,6 +255,28 @@ describe('VariableList', function () { }); }); + describe('.assimilate', function () { + it('should retain description post assimilate', function () { + const variableList = new VariableList(), + pathParams = [ + { + key: 'spacecraftId', + value: '', + description: 'PATH_PARAM_DESCRIPTION', + disabled: false + } + ]; + + variableList.add({ + key: 'spacecraftId', + value: '' + }); + variableList.assimilate(pathParams, true); + expect(variableList.members[0].description.content).to.equal('PATH_PARAM_DESCRIPTION'); + expect(variableList.members[0].description.type).to.equal('text/plain'); + }); + }); + describe('.syncToObject', function () { it('should use a default blank target object if the provided target is not an object', function () { var list = new VariableList(null, [ diff --git a/test/unit/variable.test.js b/test/unit/variable.test.js index 2a4ae9f6a..5eb44a96e 100644 --- a/test/unit/variable.test.js +++ b/test/unit/variable.test.js @@ -12,7 +12,7 @@ describe('Variable', function () { }); it('should initialize variable with correct system value', function () { - var v = new Variable(); + let v = new Variable(); expect(v.system).to.be.undefined; @@ -28,7 +28,7 @@ describe('Variable', function () { }); it('should update the sytem property of a variable', function () { - var v = new Variable(); + let v = new Variable(); v.update({ system: true }); expect(v.system).to.be.true; @@ -40,8 +40,21 @@ describe('Variable', function () { expect(v.system).to.be.false; }); + it('should update the description property of a variable', function () { + let v = new Variable(); + + v.update({ description: 'Hello' }); + expect(v.description.content).to.equal('Hello'); + + v = new Variable({ + description: true + }); + v.update({ description: 'world' }); + expect(v.description.content).to.equal('world'); + }); + it('should update the disabled property of a variable', function () { - var v = new Variable(); + let v = new Variable(); v.update({ disabled: true }); expect(v.disabled).to.be.true; @@ -54,7 +67,7 @@ describe('Variable', function () { }); it('should prepopulate value and type when passed to the constructor (string)', function () { - var v = new Variable({ + let v = new Variable({ value: 'Picard', type: 'string' }); @@ -66,7 +79,7 @@ describe('Variable', function () { }); it('should prepopulate value and type when passed to the constructor (number)', function () { - var v = new Variable({ + let v = new Variable({ value: 42, type: 'number' }); @@ -78,7 +91,7 @@ describe('Variable', function () { }); it('should prepopulate value and type when passed to the constructor (boolean)', function () { - var v = new Variable({ + let v = new Variable({ value: true, type: 'boolean' }); From 908e442e33f61c54e2ac00eab63f9a12797bca57 Mon Sep 17 00:00:00 2001 From: Udit Vasu Date: Mon, 11 Sep 2023 18:05:43 +0530 Subject: [PATCH 2/3] Update dependencies --- CHANGELOG.yaml | 8 ++++++++ package-lock.json | 6 +++--- package.json | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index e340752c4..106cc1d75 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -1,3 +1,11 @@ +unreleased: + fixed bugs: + - >- + GH-1332 Fixed a bug where `Variable~update` was not updating the + description + chores: + - Updated dependencies + 4.2.0: date: 2023-08-03 new features: diff --git a/package-lock.json b/package-lock.json index cb162a22a..800ed0b12 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1605,9 +1605,9 @@ } }, "chai": { - "version": "4.3.7", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.7.tgz", - "integrity": "sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==", + "version": "4.3.8", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.8.tgz", + "integrity": "sha512-vX4YvVVtxlfSZ2VecZgFUTU5qPCYsobVI2O9FmwEXBhDigYGQA6jRXCycIs1yJnnWbZ6/+a2zNIF5DfVCcJBFQ==", "dev": true, "requires": { "assertion-error": "^1.1.0", diff --git a/package.json b/package.json index 86549c6d3..a3aa328f4 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "bipbip": "^0.4.2", "browserify": "^17.0.0", "btoa": "^1.2.1", - "chai": "^4.3.7", + "chai": "^4.3.8", "chalk": "^4.1.2", "dependency-check": "^4.1.0", "eslint": "^7.32.0", From 159a22bf65bb9783525853cb4d0da24ae407ff4b Mon Sep 17 00:00:00 2001 From: Udit Vasu Date: Mon, 11 Sep 2023 18:08:14 +0530 Subject: [PATCH 3/3] Release v4.2.1 --- CHANGELOG.yaml | 3 ++- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.yaml b/CHANGELOG.yaml index 106cc1d75..df8c18a38 100644 --- a/CHANGELOG.yaml +++ b/CHANGELOG.yaml @@ -1,4 +1,5 @@ -unreleased: +4.2.1: + date: 2023-09-11 fixed bugs: - >- GH-1332 Fixed a bug where `Variable~update` was not updating the diff --git a/package-lock.json b/package-lock.json index 800ed0b12..cfea79832 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "postman-collection", - "version": "4.2.0", + "version": "4.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a3aa328f4..6143da72b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "postman-collection", - "version": "4.2.0", + "version": "4.2.1", "description": "Enables developers to use a unified Postman Collection format Object across projects", "author": "Postman Inc.", "license": "Apache-2.0",