Skip to content

Commit

Permalink
[test] CollectionView
Browse files Browse the repository at this point in the history
when a collection view is DOM
* and it's not attached to the document
** should have a child view without `_isAttached`

* and it's attached to the document
** should have a child view with `_isAttached` set to `true`
  • Loading branch information
rafde committed Aug 24, 2016
1 parent 5d74ec1 commit 5034c32
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test/unit/collection-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,38 @@ describe('collection view', function() {

describe('when a collection view is DOM', function() {
beforeEach(function() {
this.$fixtureEl = $('<div id="fixture-collectionview"></div>');
this.$fixtureEl = $('<div id="fixture-collectionview"><span id="el1">1</span></div>');
});

describe('and it\'s not attached to the document', function() {
beforeEach(function() {
this.collectionView = new this.CollectionView({el: '#fixture-collectionview'});
this.collectionView = new this.CollectionView({el: this.$fixtureEl[0]});
this.view1 = this.collectionView.addChildView(new Backbone.View({el: this.$fixtureEl.children()[0]}), 0);
});

it('should have _isAttached set to false', function() {
expect(this.collectionView).to.have.property('_isAttached', false);
});

it('should have a child view without _isAttached', function() {
expect(this.view1).to.not.have.property('_isAttached');
});
});

describe('and it\'s attached to the document', function() {
beforeEach(function() {
this.setFixtures(this.$fixtureEl);
this.collectionView = new this.CollectionView({el: '#fixture-collectionview'});
this.view1 = this.collectionView.addChildView(new Backbone.View({el: '#el1'}), 0);
});

it('should have _isAttached set to true', function() {
expect(this.collectionView).to.have.property('_isAttached', true);
});

it('should have a child view with _isAttached set to true', function() {
expect(this.view1).to.have.property('_isAttached', true);
});
});

});
Expand Down

0 comments on commit 5034c32

Please sign in to comment.