/
behaviors.spec.js
800 lines (655 loc) · 24.8 KB
/
behaviors.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
describe('Behaviors', function() {
'use strict';
describe('behavior lookup', function() {
it('should throw if behavior lookup is not defined', function() {
expect(function() {
Marionette.Behaviors.behaviorsLookup();
}).to.throw(Marionette.Error, new Marionette.Error({
message: 'You must define where your behaviors are stored.',
url: 'marionette.behaviors.md#behaviorslookup'
}));
});
});
describe('behavior parsing with a functional behavior lookup', function() {
beforeEach(function() {
this.behaviors = {
foo: this.sinon.spy(Marionette, "Behavior")
};
Marionette.Behaviors.behaviorsLookup = _.bind(function() {
return this.behaviors;
}, this);
});
describe('when one behavior', function() {
beforeEach(function() {
this.View = Marionette.ItemView.extend({
behaviors: { foo: {} }
});
this.view = new this.View();
});
it('should instantiate the behavior', function() {
expect(this.behaviors.foo).to.have.been.calledOnce;
});
});
});
describe('behavior parsing', function() {
beforeEach(function() {
this.behaviors = {
foo: this.sinon.spy(Marionette, "Behavior")
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
});
describe('when one behavior', function() {
beforeEach(function() {
this.View = Marionette.ItemView.extend({
behaviors: { foo: {} }
});
this.view = new this.View();
});
it('should instantiate the behavior', function() {
expect(this.behaviors.foo).to.have.been.calledOnce;
});
});
describe('when multiple behaviors', function() {
beforeEach(function() {
this.View = Marionette.ItemView.extend({
behaviors: { foo: {} }
});
this.view = new this.View();
});
it('should instantiate the behavior', function() {
expect(this.behaviors.foo).to.have.been.calledOnce;
});
});
describe('when functional behavior', function() {
beforeEach(function() {
this.behaviorsStub = this.sinon.stub().returns({
foo: { behaviorClass: this.behaviors.foo }
});
this.View = Marionette.ItemView.extend({
behaviors: this.behaviorsStub
});
this.view = new this.View();
});
it('should instantiate the behavior', function() {
expect(this.behaviors.foo).to.have.been.calledOnce;
});
it('should call the behaviors method with the view context', function() {
expect(this.behaviorsStub).to.have.been.calledOnce.and.calledOn(this.view);
});
});
describe('when behavior class is provided', function() {
beforeEach(function() {
this.View = Marionette.ItemView.extend({
behaviors: { foo: { behaviorClass: this.behaviors.foo } }
});
this.view = new this.View();
});
it('should instantiate the behavior', function() {
expect(this.behaviors.foo).to.have.been.calledOnce;
});
});
});
describe('behavior initialize', function() {
beforeEach(function() {
this.behaviorOptions = { foo: 'bar' };
this.initializeStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({ initialize: this.initializeStub })
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.ItemView.extend({
behaviors: { foo: this.behaviorOptions }
});
this.view = new this.View();
});
it('should call initialize when a behavior is created', function() {
expect(this.initializeStub).to.have.been.calledOnce;
});
it('should call initialize when a behavior is created', function() {
expect(this.initializeStub).to.have.been.calledOnce.and.calledWith(this.behaviorOptions, this.view);
});
it('should set _behaviors', function() {
expect(this.view._behaviors.length).to.be.equal(1);
});
});
describe('behavior events', function() {
beforeEach(function() {
this.fooClickStub = this.sinon.stub();
this.barClickStub = this.sinon.stub();
this.bazClickStub = this.sinon.stub();
this.viewClickStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({
events: { 'click': this.fooClickStub }
}),
bar: Marionette.Behavior.extend({
events: { 'click': this.barClickStub }
}),
baz: Marionette.Behavior.extend({
events: { 'click': 'handleClick' },
handleClick: this.bazClickStub
})
};
this.View = Marionette.ItemView.extend({
events: { 'click': this.viewClickStub },
behaviors: { foo: {}, bar: {}, baz: {} }
});
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.view = new this.View();
this.view.$el.click();
});
it('should call first behaviors event', function() {
expect(this.fooClickStub).to.have.been.calledOnce.and.calledOn(sinon.match.instanceOf(this.behaviors.foo));
});
it('should call second behaviors event', function() {
expect(this.barClickStub).to.have.been.calledOnce.and.calledOn(sinon.match.instanceOf(this.behaviors.bar));
});
it('should call third behaviors event', function() {
expect(this.bazClickStub).to.have.been.calledOnce.and.calledOn(sinon.match.instanceOf(this.behaviors.baz));
});
it('should call the view click handler', function() {
expect(this.viewClickStub).to.have.been.calledOnce.and.calledOn(this.view);
});
});
describe('behavior triggers', function() {
beforeEach(function() {
this.onClickFooStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({
triggers: { 'click': 'click:foo' },
onClickFoo: this.onClickFooStub
})
};
this.model = new Backbone.Model();
this.collection = new Backbone.Collection();
this.View = Marionette.ItemView.extend({
behaviors: { foo: {} }
});
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.view = new this.View({
model: this.model,
collection: this.collection
});
this.triggerMethodSpy = this.sinon.spy();
this.view.on('click:foo', this.triggerMethodSpy);
this.view.$el.click();
});
it('calls `triggerMethod` with the triggered event', function() {
expect(this.triggerMethodSpy)
.to.have.been.calledOnce
.and.calledOn(this.view);
});
it('calls the triggered method', function() {
expect(this.onClickFooStub)
.to.have.been.calledOnce
.and.have.been.calledOn(sinon.match.instanceOf(this.behaviors.foo));
});
});
describe('behavior $el', function() {
beforeEach(function() {
var suite = this;
this.behaviors = {
foo: Marionette.Behavior.extend({
initialize: function () { suite.fooBehavior = this; }
})
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.ItemView.extend({
behaviors: { foo: {} }
});
this.view = new this.View();
this.view.setElement(document.createElement('bar'));
});
it('should proxy the views $el', function() {
expect(this.fooBehavior.$el).to.equal(this.view.$el);
});
it('should proxy the views el', function() {
expect(this.fooBehavior.el).to.equal(this.view.el);
});
});
describe('behavior UI', function() {
beforeEach(function() {
var suite = this;
this.onRenderStub = this.sinon.stub();
this.onBeforeShowStub = this.sinon.stub();
this.onShowStub = this.sinon.stub();
this.onDestroyStub = this.sinon.stub();
this.onFooClickStub = this.sinon.stub();
this.onBarClickStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({
ui: { foo: '.foo' },
initialize: function() { suite.fooBehavior = this; },
events: {
'click @ui.foo': 'onFooClick',
'click @ui.bar': 'onBarClick'
},
onRender : this.onRenderStub,
onBeforeShow : this.onBeforeShowStub,
onShow : this.onShowStub,
onDestroy : this.onDestroyStub,
onFooClick : this.onFooClickStub,
onBarClick : this.onBarClickStub
})
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.ItemView.extend({
template: _.template('<div class="foo"></div><div class="bar"></div>'),
ui: { bar: '.bar' },
behaviors: { foo: {} }
});
});
describe('should call onShow when inside a CollectionView', function() {
beforeEach(function() {
this.CollectionView = Marionette.CollectionView.extend({
childView: this.View
});
this.collection = new Backbone.Collection([{}]);
this.collectionView = new this.CollectionView({collection: this.collection});
this.collectionView.render();
this.collectionView.triggerMethod('show');
});
it('should call onShow when inside a CollectionView', function() {
expect(this.onShowStub).to.have.been.called;
});
it('should call onShow when already shown and reset', function() {
this.collection.reset([{id:1}, {id: 2}]);
expect(this.onShowStub.callCount).to.equal(3);
});
it('should call onShow when a single model is added and the collectionView is already shown', function() {
this.collection.add({id: 3});
expect(this.onShowStub.callCount).to.equal(2);
});
});
describe('within a view', function() {
beforeEach(function() {
this.view = new this.View();
this.view.render();
});
it('should not clobber the event prototype', function() {
expect(this.behaviors.foo.prototype.events).to.have.property('click @ui.bar', 'onBarClick');
});
it('should handle click events after calling delegateEvents', function() {
this.view.delegateEvents();
expect(this.fooBehavior.ui.foo.click.bind(this.view.ui.bar)).to.not.throw(Error);
expect(this.view.ui.bar.click.bind(this.view.ui.bar)).to.not.throw(Error);
});
it('should set the behavior UI element', function() {
expect(this.onRenderStub).to.have.been.calledOnce;
});
describe("the $el", function() {
beforeEach(function() {
this.view.$el.find('.foo').click();
this.view.$el.find('.bar').click();
});
it('should handle behavior ui click event', function() {
expect(this.onFooClickStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
it('should handle view ui click event', function() {
expect(this.onBarClickStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
});
describe("the el", function() {
beforeEach(function() {
$(this.view.el).find('.foo').click();
$(this.view.el).find('.bar').click();
});
it('should handle behavior ui click event', function() {
expect(this.onFooClickStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
it('should handle view ui click event', function() {
expect(this.onBarClickStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
});
});
describe('within a layout', function() {
beforeEach(function() {
this.LayoutView = Marionette.LayoutView.extend({
template: _.template('<div class="baz"></div>'),
regions: { bazRegion: '.baz' }
});
this.layoutView = new this.LayoutView();
this.layoutView.render();
this.layoutView.bazRegion.show(new this.View());
this.layoutView.destroy();
});
it('should call onBeforeShow', function() {
expect(this.onBeforeShowStub).to.have.been.calledOnce;
});
it('should call onShow', function() {
expect(this.onShowStub).to.have.been.calledOnce;
});
it('should call onDestroy', function() {
expect(this.onDestroyStub).to.have.been.calledOnce;
});
});
});
describe('showing a view in a layout', function() {
beforeEach(function() {
this.onShowStub = this.sinon.stub();
this.onDestroyStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({
onShow : this.onShowStub,
onDestroy : this.onDestroyStub
})
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.ItemView.extend({
template: _.template('foo'),
behaviors: { foo: {} }
});
this.region = new Backbone.Marionette.Region({ el: $('<div>') });
this.view = new this.View();
this.region.show(this.view);
this.region.empty();
});
it('behavior onShow is called once', function() {
expect(this.onShowStub).to.have.been.calledOnce;
});
it('behavior onClose is called once', function() {
expect(this.onDestroyStub).to.have.been.calledOnce;
});
});
describe('behavior instance events', function() {
beforeEach(function() {
var suite = this;
this.listenToChangeStub = this.sinon.stub();
this.onFooStub = this.sinon.stub();
this.model = new Backbone.Model();
this.FooBehavior = Marionette.Behavior.extend({
initialize: function() {
this.listenTo(suite.model, 'change', suite.listenToChangeStub);
this.on('foo', suite.onFooStub);
}
});
this.View = Marionette.AbstractView.extend({
behaviors: { foo: { behaviorClass: this.FooBehavior } }
});
this.view = new this.View();
this.view.destroy();
this.model.set('bar', 'baz');
this.view.triggerMethod('foo');
});
it('should unbind listenTo on destroy', function() {
expect(this.listenToChangeStub).not.to.have.been.calledOnce;
});
it('should still be bound to "on" on destroy', function() {
expect(this.onFooStub).to.have.been.calledOnce;
});
});
describe('behavior model events', function() {
beforeEach(function() {
var suite = this;
this.handleModelChangeStub = this.sinon.stub();
this.handleCollectionResetStub = this.sinon.stub();
this.handleModelFooChangeStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({
initialize: function() { suite.fooBehavior = this; },
modelEvents: {
'change': this.handleModelChangeStub,
'change:foo': 'handleModelFooChange'
},
collectionEvents: {
'reset': this.handleCollectionResetStub
},
handleModelFooChange: this.handleModelFooChangeStub
})
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.CollectionView = Marionette.CollectionView.extend({
behaviors: { foo: {} }
});
this.ItemView = Marionette.ItemView.extend({
behaviors: { foo: {} }
});
this.model = new Backbone.Model({ foo: 'bar' });
this.collection = new Backbone.Collection([]);
});
it('should proxy model events', function() {
this.view = new this.ItemView({ model: this.model });
this.model.set('foo', 'baz');
expect(this.handleModelChangeStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
it('should proxy model events w/ string cbk', function() {
this.view = new this.ItemView({ model: this.model });
this.model.set('foo', 'baz');
expect(this.handleModelFooChangeStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
it('should proxy collection events', function() {
this.view = new this.CollectionView({ collection: this.collection });
this.collection.reset();
expect(this.handleCollectionResetStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
it('should unbind model events on view undelegateEntityEvents', function() {
this.view = new this.ItemView({ model: this.model });
this.view.undelegateEntityEvents();
this.model.set('foo', 'doge');
expect(this.handleModelFooChangeStub).not.to.have.been.called;
});
it('should unbind collection events on view undelegateEntityEvents', function() {
this.view = new this.CollectionView({ collection: this.collection });
this.view.undelegateEntityEvents();
this.collection.reset();
expect(this.handleCollectionResetStub).not.to.have.been.called;
});
});
describe('behavior trigger calls', function() {
beforeEach(function() {
this.onRenderStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({
onRender: this.onRenderStub
})
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.AbstractView.extend({
behaviors: { foo: {} }
});
this.view = new this.View();
this.view.triggerMethod('render');
});
it('should call onRender when a view is rendered', function() {
expect(this.onRenderStub).to.have.been.calledOnce;
});
});
describe('behavior triggerMethod calls', function() {
beforeEach(function() {
this.behaviors = {
foo: Marionette.Behavior.extend({
onFoo: function() {
return "behavior foo";
}
})
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.AbstractView.extend({
behaviors: { foo: {} },
onFoo: function() {
return "view foo";
}
});
this.view = new this.View();
});
it('onFoo should return "foo"', function() {
expect(this.view.triggerMethod('foo')).to.equal('view foo');
});
});
describe('behavior is evented', function() {
beforeEach(function() {
this.listenToStub = this.sinon.stub();
this.changeStub = this.sinon.stub();
this.behavior = new Marionette.Behavior({}, {});
this.model = new Backbone.Model();
Marionette.bindEntityEvents(this.behavior, this.model, {
'change': this.changeStub
});
this.behavior.listenTo(this.model, 'foo', this.listenToStub);
this.model.trigger('foo');
this.model.set('foo', 'bar');
});
it('should listenTo events', function() {
expect(this.listenToStub).to.have.been.calledOnce;
});
it('should support bindEntityEvents', function() {
expect(this.changeStub).to.have.been.calledOnce;
});
it('should execute in the specified context', function() {
expect(this.listenToStub).to.have.been.calledOnce.and.calledOn(this.behavior);
});
});
describe('behavior with behavior', function() {
beforeEach(function() {
var suite = this;
this.initializeStub = this.sinon.stub();
this.viewOnRenderStub = this.sinon.stub();
this.fooClickStub = this.sinon.stub();
this.barOnRenderStub = this.sinon.stub();
this.barClickStub = this.sinon.stub();
this.barModelChangeStub = this.sinon.stub();
this.barCollectionSyncStub = this.sinon.stub();
this.viewOnRenderStub = this.sinon.stub();
this.bazClickStub = this.sinon.stub();
this.behaviors = {
foo: Marionette.Behavior.extend({
initialize: function() { suite.fooBehavior = this; },
behaviors: { bar: {} },
ui: { foo: '.foo' },
events: {
'click @ui.foo': this.fooClickStub
}
}),
bar: Marionette.Behavior.extend({
initialize: function() {
suite.initializeStub();
suite.barBehavior = this;
},
onRender: this.barOnRenderStub,
ui: { bar: '.bar' },
events: {
'click @ui.bar': this.barClickStub
},
modelEvents: {
'change': this.barModelChangeStub
},
collectionEvents: {
'sync': this.barCollectionSyncStub
}
})
};
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.CompositeView.extend({
template: _.template('<div class="baz"></div><div class="foo"></div><div class="bar"></div>'),
behaviors: { foo: {} },
onRender: this.viewOnRenderStub,
ui: { baz: '.baz' },
events: {
'click @ui.baz': this.bazClickStub,
}
});
this.model = new Backbone.Model();
this.collection = new Backbone.Collection();
this.view = new this.View({
model : this.model,
collection : this.collection
});
this.sinon.spy(this.view, 'undelegateEvents');
this.sinon.spy(this.view, 'undelegateEntityEvents');
});
it('should call initialize on grouped behaviors', function() {
expect(this.initializeStub).to.have.been.calledOnce;
});
it('should set _behaviors', function() {
expect(this.view._behaviors.length).to.be.equal(2);
});
it('should call onRender on grouped behaviors', function() {
this.view.triggerMethod('render');
expect(this.barOnRenderStub).to.have.been.calledOnce.and.calledOn(this.barBehavior);
});
it('should call onRender on the view', function() {
this.view.triggerMethod('render');
expect(this.viewOnRenderStub).to.have.been.calledOnce.and.calledOn(this.view);
});
it('should call undelegateEvents once', function() {
this.view.undelegateEvents();
expect(this.view.undelegateEvents).to.have.been.calledOnce;
});
it('should call undelegateEntityEvents once', function() {
this.view.undelegateEntityEvents();
expect(this.view.undelegateEntityEvents).to.have.been.calledOnce;
});
it('should proxy modelEvents to grouped behaviors', function() {
this.model.trigger('change');
expect(this.barModelChangeStub).to.have.been.calledOnce.and.calledOn(this.barBehavior);
});
it('should proxy collectionEvents to grouped behaviors', function() {
this.collection.trigger('sync');
expect(this.barCollectionSyncStub).to.have.been.calledOnce.and.calledOn(this.barBehavior);
});
it('should proxy child behavior UI events to grouped behaviors', function() {
this.view.render();
this.barBehavior.ui.bar.click();
expect(this.barClickStub).to.have.been.calledOnce.and.calledOn(this.barBehavior);
});
it('should proxy base behavior UI events to base behavior', function() {
this.view.render();
this.fooBehavior.ui.foo.click();
expect(this.fooClickStub).to.have.been.calledOnce.and.calledOn(this.fooBehavior);
});
it('should proxy view UI events to view', function() {
this.view.render();
this.view.ui.baz.click();
expect(this.bazClickStub).to.have.been.calledOnce.and.calledOn(this.view);
});
});
describe('return values of wrapped methods', function() {
beforeEach(function() {
this.behaviors = { foo: Marionette.Behavior };
Marionette.Behaviors.behaviorsLookup = this.behaviors;
this.View = Marionette.AbstractView.extend({
behaviors: { foo: {} }
});
this.view = new this.View();
});
it('destroy should return the view', function() {
this.sinon.spy(this.view, 'destroy');
this.view.destroy();
expect(this.view.destroy).to.have.returned(this.view);
});
it('setElement should return the view', function() {
this.sinon.spy(this.view, 'setElement');
this.view.setElement(this.view.$el);
expect(this.view.setElement).to.have.returned(this.view);
});
it('delegateEvents should return the view', function() {
this.sinon.spy(this.view, 'delegateEvents');
this.view.delegateEvents();
expect(this.view.delegateEvents).to.have.returned(this.view);
});
it('undelegateEvents should return the view', function() {
this.sinon.spy(this.view, 'undelegateEvents');
this.view.undelegateEvents({});
expect(this.view.undelegateEvents).to.have.returned(this.view);
});
it('delegateEntityEvents should return the view', function() {
this.sinon.spy(this.view, 'delegateEntityEvents');
this.view.delegateEntityEvents();
expect(this.view.delegateEntityEvents).to.have.returned(this.view);
});
it('undelegateEntityEvents should return the view', function() {
this.sinon.spy(this.view, 'undelegateEntityEvents');
this.view.undelegateEntityEvents({});
expect(this.view.undelegateEntityEvents).to.have.returned(this.view);
});
});
describe('.destroy', function() {
beforeEach(function() {
this.behavior = new Marionette.Behavior();
this.sinon.spy(this.behavior, 'destroy');
this.behavior.destroy();
});
it('should return the behavior', function() {
});
});
});