Skip to content

Commit

Permalink
Test for regions during layoutview initialize
Browse files Browse the repository at this point in the history
I also moved the initialize in the generic layoutview down to the only test it was used in.
  • Loading branch information
paulfalgout authored and samccone committed Sep 9, 2014
1 parent 6934e2a commit 769a689
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions spec/javascripts/layoutView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ describe('layoutView', function() {
regions: {
regionOne: '#regionOne',
regionTwo: '#regionTwo'
},
initialize: function() {
if (this.model) {
this.listenTo(this.model, 'change', this.render);
}
}
});

Expand All @@ -37,13 +32,24 @@ describe('layoutView', function() {

describe('on instantiation', function() {
beforeEach(function() {
this.layoutViewManager = new this.LayoutView();
var suite = this;
this.LayoutViewInitialize = this.LayoutView.extend({
initialize: function() {
suite.regionOne = this.regionOne;
}
});

this.layoutViewManager = new this.LayoutViewInitialize();
});

it('should instantiate the specified region managers', function() {
expect(this.layoutViewManager).to.have.property('regionOne');
expect(this.layoutViewManager).to.have.property('regionTwo');
});

it('should instantiate the specified region before initialize', function() {
expect(this.regionOne).to.equal(this.layoutViewManager.regionOne);
});
});

describe('on instantiation with no regions defined', function() {
Expand Down Expand Up @@ -84,7 +90,7 @@ describe('layoutView', function() {
this.layoutViewManager = new this.LayoutViewCustomRegion();
});

it('should instantiate specific regions with custom regions if speficied', function() {
it('should instantiate specific regions with custom regions if specified', function() {
expect(this.layoutViewManager).to.have.property('regionOne');
expect(this.layoutViewManager.regionOne).to.be.instanceof(this.CustomRegion1);
expect(this.layoutViewManager).to.have.property('regionTwo');
Expand Down Expand Up @@ -217,7 +223,15 @@ describe('layoutView', function() {

describe('when re-rendering an already rendered layoutView', function() {
beforeEach(function() {
this.layoutView = new this.LayoutView({
this.LayoutViewBoundRender = this.LayoutView.extend({
initialize: function() {
if (this.model) {
this.listenTo(this.model, 'change', this.render);
}
}
});

this.layoutView = new this.LayoutViewBoundRender({
model: new Backbone.Model()
});
this.layoutView.render();
Expand Down

0 comments on commit 769a689

Please sign in to comment.