Skip to content

Commit d84f1ee

Browse files
[APITEST-766] Added test changes for packages
1 parent d4447f2 commit d84f1ee

File tree

8 files changed

+42
-17
lines changed

8 files changed

+42
-17
lines changed

examples/collection-v2.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@
4242
"id": "my-global-script-1",
4343
"script": {
4444
"type": "text/javascript",
45-
"exec": "console.log(\"hello\");"
45+
"exec": "console.log(\"hello\");",
46+
"packages": [{ "id":"script-package-1", "name":"package1"}]
4647
}
4748
},
4849
{
4950
"listen": "prerequest",
5051
"script": {
5152
"type": "text/javascript",
52-
"exec": "console.log(\"hello\");"
53+
"exec": "console.log(\"hello\");",
54+
"packages": [{ "id":"script-package-1", "name":"package1"}]
5355
}
5456
}
5557
],

lib/collection/script.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ _.assign(Script.prototype, /** @lends Script.prototype */ {
4949
* @param {String} [options.type] Script type
5050
* @param {String} [options.src] Script source url
5151
* @param {String[]|String} [options.exec] Script to execute
52+
* @param {Object[]} [options.packages] Packages required by the script
5253
*/
5354
update: function (options) {
5455
// no splitting is being done here, as string scripts are split right before assignment below anyway

test/unit/collection.test.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ describe('Collection', function () {
2525
script: {
2626
id: 'my-script-1',
2727
type: 'text/javascript',
28-
exec: ['console.log("This doesn\'t matter");']
28+
exec: ['console.log("This doesn\'t matter");'],
29+
packages: []
2930
}
3031
}]
3132
},
@@ -178,7 +179,8 @@ describe('Collection', function () {
178179
script: {
179180
id: 'test-script-1',
180181
type: 'text/javascript',
181-
exec: ['console.log("Random");']
182+
exec: ['console.log("Random");'],
183+
packages: []
182184
}
183185
});
184186
expect(collectionJSON.event[1]).to.have.property('listen', 'prerequest');
@@ -218,6 +220,12 @@ describe('Collection', function () {
218220
type: 'text/javascript',
219221
exec: [
220222
'console.log("bcoz I am batman!");'
223+
],
224+
packages: [
225+
{
226+
id: 'my-package-1',
227+
name: 'superman',
228+
}
221229
]
222230
}
223231
}],
@@ -280,7 +288,8 @@ describe('Collection', function () {
280288
type: 'text/javascript',
281289
exec: [
282290
'console.log("bcoz I am batman!");'
283-
]
291+
],
292+
packages: [{ id: 'my-package-1', name: 'superman' }]
284293
}
285294
}],
286295
item: [{

test/unit/event-list.test.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ describe('EventList', function () {
1010
id: 'my-global-script-1',
1111
script: {
1212
type: 'text/javascript',
13-
exec: 'console.log("hello");'
13+
exec: 'console.log("hello");',
14+
packages: [{ id: 'script-package-1', name: 'package1'}]
1415
}
1516
}];
1617

@@ -35,7 +36,8 @@ describe('EventList', function () {
3536
script: {
3637
id: 'test-script-1',
3738
type: 'text/javascript',
38-
exec: 'console.log("hello");'
39+
exec: 'console.log("hello");',
40+
packages: [{ id: 'script-package-1', name: 'package1'}]
3941
}
4042
}]),
4143
eventListJSON;
@@ -46,7 +48,8 @@ describe('EventList', function () {
4648
script: {
4749
id: 'test-script-1',
4850
type: 'text/javascript',
49-
exec: ['console.log("hello");']
51+
exec: ['console.log("hello");'],
52+
packages: [{ id: 'script-package-1', name: 'package1'}]
5053
}
5154
}]);
5255

@@ -63,7 +66,8 @@ describe('EventList', function () {
6366
script: {
6467
id: 'test-script-1',
6568
type: 'text/javascript',
66-
exec: ['console.log("hello");']
69+
exec: ['console.log("hello");'],
70+
packages: [{ id: 'script-package-1', name: 'package1'}]
6771
}
6872
});
6973

test/unit/event.test.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ describe('Event', function () {
1111
id: 'my-global-script-1',
1212
script: {
1313
type: 'text/javascript',
14-
exec: 'console.log("hello");'
14+
exec: 'console.log("hello");',
15+
packages: []
1516
}
1617
};
1718

@@ -52,6 +53,7 @@ describe('Event', function () {
5253
expect(postmanEvent).to.have.property('script').that.is.an('object');
5354
expect(postmanEvent.script).to.have.property('type', 'text/javascript');
5455
expect(postmanEvent.script).to.have.property('exec').that.is.an('array');
56+
expect(postmanEvent.script).to.have.property('packages').that.is.an('array');
5557
});
5658
});
5759

@@ -120,7 +122,8 @@ describe('Event', function () {
120122
expect(eventJSON).to.have.property('script').that.has.property('id');
121123
expect(eventJSON.script).to.deep.include({
122124
type: 'text/javascript',
123-
exec: ['console.log("hello");']
125+
exec: ['console.log("hello");'],
126+
packages: []
124127
});
125128
});
126129

@@ -132,7 +135,8 @@ describe('Event', function () {
132135
expect(beforeJSON).to.have.property('script').that.has.property('id');
133136
expect(beforeJSON.script).to.deep.include({
134137
type: 'text/javascript',
135-
exec: ['console.log("hello");']
138+
exec: ['console.log("hello");'],
139+
packages: []
136140
});
137141

138142
event.update({ script: { id: 'my-new-script' } });

test/unit/item-group.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ describe('ItemGroup', function () {
2727
script: {
2828
id: 'my-script-1',
2929
type: 'text/javascript',
30-
exec: ['console.log("This doesn\'t matter");']
30+
exec: ['console.log("This doesn\'t matter");'],
31+
packages: [{ id: 'my-package-1', name: 'package1' }]
3132
}
3233
}],
3334
protocolProfileBehavior: {
@@ -527,7 +528,8 @@ describe('ItemGroup', function () {
527528
script: {
528529
id: 'my-test-script',
529530
type: 'text/javascript',
530-
exec: ['console.log("hello there!");']
531+
exec: ['console.log("hello there!");'],
532+
packages: [{ id: 'my-package-1', name: 'package1' }]
531533
}
532534
}],
533535
item: [{

test/unit/item.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ describe('Item', function () {
1818
script: {
1919
id: 'my-script-1',
2020
type: 'text/javascript',
21-
exec: ['console.log("This doesn\'t matter");']
21+
exec: ['console.log("This doesn\'t matter");'],
22+
packages: [{ id: 'script-package-1', name: 'package1' }]
2223
}
2324
}],
2425
request: {

test/unit/script.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ describe('Script', function () {
8989
expect(scriptJSON).to.have.property('id');
9090
expect(scriptJSON).to.deep.include({
9191
type: 'text/javascript',
92-
exec: ['console.log("This is a line of test script code");']
92+
exec: ['console.log("This is a line of test script code");'],
93+
packages: []
9394
});
9495
});
9596

@@ -201,7 +202,8 @@ describe('Script', function () {
201202

202203
expect(jsonified).to.deep.include({
203204
type: rawScript.type,
204-
exec: rawScript.exec.split('\n')
205+
exec: rawScript.exec.split('\n'),
206+
packages: rawScript.packages
205207
});
206208
expect(jsonified.src).to.eql(rawScript.src);
207209
});

0 commit comments

Comments
 (0)