Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CollectionView to be populated with pre-rendered DOM #3135

Merged
merged 4 commits into from
Aug 30, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[test] CollectionView
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
commit 5034c325da50864be196efb5a8aec6b3789af02f
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