File tree Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Expand file tree Collapse file tree 4 files changed +45
-2
lines changed Original file line number Diff line number Diff line change
1
+ unreleased :
2
+ new features :
3
+ - GH-1369 Added `isEvent` method in Event class
4
+
1
5
4.4.1 :
2
6
date : 2024-07-29
3
7
fixed bugs :
Original file line number Diff line number Diff line change @@ -87,7 +87,18 @@ _.assign(Event, /** @lends Event */ {
87
87
* @readOnly
88
88
* @type {String }
89
89
*/
90
- _postman_propertyName : 'Event'
90
+ _postman_propertyName : 'Event' ,
91
+
92
+ /**
93
+ * Check whether an object is an instance of {@link Event}.
94
+ *
95
+ * @param {* } obj -
96
+ * @returns {Boolean }
97
+ */
98
+ isEvent : function isPostmanEvent ( obj ) {
99
+ return Boolean ( obj ) && ( ( obj instanceof Event ) ||
100
+ _ . inSuperChain ( obj . constructor , '_postman_propertyName' , Event . _postman_propertyName ) ) ;
101
+ }
91
102
} ) ;
92
103
93
104
module . exports = {
Original file line number Diff line number Diff line change @@ -168,4 +168,27 @@ describe('Event', function () {
168
168
expect ( afterJSON . script ) . to . not . have . property ( 'packages' ) ;
169
169
} ) ;
170
170
} ) ;
171
+
172
+ describe ( 'isEvent' , function ( ) {
173
+ var rawEvent = {
174
+ listen : 'test' ,
175
+ id : 'my-global-script-1' ,
176
+ script : {
177
+ type : 'text/javascript' ,
178
+ exec : 'console.log("hello");'
179
+ }
180
+ } ;
181
+
182
+ it ( 'should return true for an Event instance' , function ( ) {
183
+ expect ( Event . isEvent ( new Event ( rawEvent ) ) ) . to . be . true ;
184
+ } ) ;
185
+
186
+ it ( 'should return false for a raw Event object' , function ( ) {
187
+ expect ( Event . isEvent ( rawEvent ) ) . to . be . false ;
188
+ } ) ;
189
+
190
+ it ( 'should return false when called without arguments' , function ( ) {
191
+ expect ( Event . isEvent ( ) ) . to . be . false ;
192
+ } ) ;
193
+ } ) ;
171
194
} ) ;
Original file line number Diff line number Diff line change 1
- // Type definitions for postman-collection 4.4.0
1
+ // Type definitions for postman-collection 4.4.1
2
2
// Project: https://github.com/postmanlabs/postman-collection
3
3
// Definitions by: PostmanLabs
4
4
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -649,6 +649,11 @@ declare module "postman-collection" {
649
649
* The script that is to be executed when this event is triggered.
650
650
*/
651
651
script : Script ;
652
+ /**
653
+ * Check whether an object is an instance of Event.
654
+ * @param obj - -
655
+ */
656
+ static isEvent ( obj : any ) : boolean ;
652
657
}
653
658
654
659
export namespace FormParam {
You can’t perform that action at this time.
0 commit comments