@@ -18,21 +18,21 @@ pavlov.specify("Backbone.Geppetto", function(){
1818 } ) ;
1919
2020 } ) ;
21-
21+
2222 describe ( "when binding a context" , function ( ) {
23-
23+
2424 var contextDefinition ;
2525 var contextInstance ;
26-
26+
2727 before ( function ( ) {
2828 contextDefinition = Geppetto . Context . extend ( ) ;
2929 } ) ;
3030
3131 it ( "should bind the context instance to the view" , function ( ) {
32-
32+
3333 var MyViewDef = Backbone . View . extend ( ) ;
3434 var myView = new MyViewDef ( ) ;
35-
35+
3636 Geppetto . bindContext ( {
3737 view : myView ,
3838 context : contextDefinition
@@ -43,7 +43,7 @@ pavlov.specify("Backbone.Geppetto", function(){
4343 myView . close ( ) ;
4444 } ) ;
4545 } ) ;
46-
46+
4747 describe ( "when a Backbone View adds an event listener to a context" , function ( ) {
4848 var parentView ;
4949 var contextDefinition ;
@@ -108,7 +108,7 @@ pavlov.specify("Backbone.Geppetto", function(){
108108
109109 it ( "should throw an exception if the payload object is a string, not an object" , function ( ) {
110110 assert ( function ( ) {
111- contextInstance . dispatch ( "foo" , "baz" ) ;
111+ contextInstance . dispatch ( "foo" , "baz" ) ;
112112 } ) . throwsException ( "Event payload must be an object" ) ;
113113 } ) ;
114114
@@ -145,12 +145,12 @@ pavlov.specify("Backbone.Geppetto", function(){
145145 } ) ;
146146
147147 it ( "should not fire the foo event when listened from the parent view and the parent view is closed" , function ( ) {
148- var parentFooSpy = sinon . spy ( ) ;
148+ var parentFooSpy = sinon . spy ( ) ;
149149 contextInstance . listen ( parentView , "foo" , parentFooSpy ) ;
150150 parentView . close ( ) ;
151151 contextInstance . dispatch ( "foo" ) ;
152152 assert ( parentFooSpy . callCount ) . isEqualTo ( 0 ) ;
153- } ) ;
153+ } ) ;
154154 } ) ;
155155
156156 describe ( "when a Backbone View specifies a contextEvents map" , function ( ) {
@@ -168,9 +168,9 @@ pavlov.specify("Backbone.Geppetto", function(){
168168 barParentSpy = sinon . spy ( ) ;
169169 fooChildSpy = sinon . spy ( ) ;
170170 barChildSpy = sinon . spy ( ) ;
171-
171+
172172 contextDefinition = Geppetto . Context . extend ( ) ;
173-
173+
174174 var ParentViewDef = Backbone . View . extend ( {
175175 initialize : function ( ) {
176176 _ . bindAll ( this ) ;
@@ -183,7 +183,7 @@ pavlov.specify("Backbone.Geppetto", function(){
183183 } ,
184184 handleFoo : function ( ) {
185185 fooParentSpy ( ) ;
186- }
186+ }
187187 } ) ;
188188 parentView = new ParentViewDef ( ) ;
189189
@@ -196,7 +196,7 @@ pavlov.specify("Backbone.Geppetto", function(){
196196
197197 var childViewDef = Backbone . View . extend ( {
198198
199- contextEvents : {
199+ contextEvents : {
200200 "foo" : "handleFoo" ,
201201 "bar" : function ( ) {
202202 barChildSpy ( ) ;
@@ -225,7 +225,7 @@ pavlov.specify("Backbone.Geppetto", function(){
225225 fooParentSpy = undefined ;
226226 barParentSpy = undefined ;
227227 fooChildSpy = undefined ;
228- barChildSpy = undefined ;
228+ barChildSpy = undefined ;
229229 } ) ;
230230
231231 it ( "should trigger the foo response function when registered as a string" , function ( ) {
@@ -239,7 +239,7 @@ pavlov.specify("Backbone.Geppetto", function(){
239239 assert ( barParentSpy . callCount ) . isEqualTo ( 1 ) ;
240240 assert ( barChildSpy . callCount ) . isEqualTo ( 1 ) ;
241241 } ) ;
242-
242+
243243 it ( "should remove the parent foo listener when the parent view is closed" , function ( ) {
244244 contextInstance . dispatch ( "foo" ) ;
245245 assert ( fooParentSpy . callCount ) . isEqualTo ( 1 ) ;
@@ -258,8 +258,8 @@ pavlov.specify("Backbone.Geppetto", function(){
258258 contextInstance . dispatch ( "foo" ) ;
259259 assert ( fooParentSpy . callCount ) . isEqualTo ( 2 ) ;
260260 assert ( fooChildSpy . callCount ) . isEqualTo ( 1 ) ;
261- } ) ;
262- } ) ;
261+ } ) ;
262+ } ) ;
263263
264264 describe ( "when registering a context listener" , function ( ) {
265265
@@ -350,7 +350,7 @@ pavlov.specify("Backbone.Geppetto", function(){
350350
351351 var abcSpy ;
352352 var xyzSpy ;
353-
353+
354354 before ( function ( ) {
355355 abcSpy = sinon . spy ( ) ;
356356 AbcCommand = function ( ) { } ;
@@ -378,7 +378,7 @@ pavlov.specify("Backbone.Geppetto", function(){
378378 after ( function ( ) {
379379 myView . close ( ) ;
380380 } ) ;
381-
381+
382382 it ( "should fire AbcCommand when abcEvent is dispatched" , function ( ) {
383383 myView . context . dispatch ( "abcEvent" ) ;
384384
@@ -394,6 +394,12 @@ pavlov.specify("Backbone.Geppetto", function(){
394394 assert ( abcSpy . called ) . isFalse ( ) ;
395395 assert ( xyzSpy . called ) . isFalse ( ) ;
396396 } ) ;
397+
398+ it ( "should throw an error if the command is not a function" , function ( ) {
399+ assert ( function ( ) {
400+ myView . context . mapCommand ( "failEvent" , { } ) ;
401+ } ) . throwsException ( 'Command must be constructable' ) ;
402+ } ) ;
397403 } ) ;
398404
399405 describe ( "when registering commands in batch using the commands map" , function ( ) {
@@ -451,7 +457,7 @@ pavlov.specify("Backbone.Geppetto", function(){
451457 assert ( abcSpy . called ) . isFalse ( ) ;
452458 assert ( xyzSpy . called ) . isFalse ( ) ;
453459 } ) ;
454- } ) ;
460+ } ) ;
455461
456462 describe ( "when a context has a parent context" , function ( ) {
457463
@@ -515,13 +521,13 @@ pavlov.specify("Backbone.Geppetto", function(){
515521
516522 var view1 ;
517523 var context1 ;
518-
524+
519525 var view2 ;
520526 var context2 ;
521527
522528 var view3 ;
523- var context3 ;
524-
529+ var context3 ;
530+
525531 before ( function ( ) {
526532
527533 var viewDef1 = Backbone . View . extend ( ) ;
@@ -530,20 +536,20 @@ pavlov.specify("Backbone.Geppetto", function(){
530536 view : view1 ,
531537 context : Geppetto . Context . extend ( )
532538 } ) ;
533-
539+
534540 var viewDef2 = Backbone . View . extend ( ) ;
535541 view2 = new viewDef2 ( ) ;
536542 context2 = Geppetto . bindContext ( {
537543 view : view2 ,
538544 context : Geppetto . Context . extend ( )
539- } ) ;
545+ } ) ;
540546
541547 var viewDef3 = Backbone . View . extend ( ) ;
542548 view3 = new viewDef3 ( ) ;
543549 context3 = Geppetto . bindContext ( {
544550 view : view3 ,
545551 context : Geppetto . Context . extend ( )
546- } ) ;
552+ } ) ;
547553
548554 } ) ;
549555
0 commit comments