@@ -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 ( 'object' ) ;
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' } } ) ;
@@ -142,5 +146,26 @@ describe('Event', function () {
142146 expect ( afterJSON . script ) . to . have . property ( 'id' , 'my-new-script' ) ;
143147 expect ( afterJSON . script . exec ) . to . be . undefined ;
144148 } ) ;
149+
150+ it ( 'should not add packages key if not present' , function ( ) {
151+ var rawEvent = {
152+ listen : 'test' ,
153+ id : 'my-global-script-1' ,
154+ script : {
155+ type : 'text/javascript' ,
156+ exec : 'console.log("hello");'
157+ }
158+ } ,
159+ event = new Event ( rawEvent ) ,
160+ beforeJSON = event . toJSON ( ) ,
161+ afterJSON ;
162+
163+ expect ( beforeJSON . script ) . to . not . have . property ( 'packages' ) ;
164+
165+ event . update ( { script : { exec : 'console.log("updated");' } } ) ;
166+ afterJSON = event . toJSON ( ) ;
167+
168+ expect ( afterJSON . script ) . to . not . have . property ( 'packages' ) ;
169+ } ) ;
145170 } ) ;
146171} ) ;
0 commit comments