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

Fix #1567 and add tests to cover getChildView taking a model #1619

Merged
merged 1 commit into from
Jul 14, 2014

Conversation

cmaher
Copy link
Member

@cmaher cmaher commented Jul 11, 2014

fixes #1567

@@ -231,6 +231,9 @@ Marionette.CollectionView = Marionette.View.extend({
// Retrieve the childView class, either from `this.options.childView`
// or from the `childView` in the object definition. The "options"
// takes precedence.
// This method receives the model that will be passed to the instance
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to wrap childView in for docco

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 945ab32 on cmaher:fix-1566 into 4b005b4 on marionettejs:v2.1.

@cmaher cmaher changed the title Fix #1566 and add tests to cover getChildView taking a model Fix #1567 and add tests to cover getChildView taking a model Jul 11, 2014
@@ -141,6 +142,12 @@ describe('collection view', function() {
it('should trigger "childview:render" for each item in the collection', function() {
expect(this.childViewRender.callCount).to.equal(2);
});

it('should call "getChildView" for each item in the collection', function() {
expect(this.collectionView.getChildView).to.have.been.calledTwice;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+ expect(this.collectionView.getChildView).to.have.been.calledTwice.and.calledWith(this.collection.models[0], this.collection.models[1])
- expect(this.collectionView.getChildView).to.have.been.calledTwice;
- expect(this.collectionView.getChildView).to.have.been.calledWith(this.collection.models[0]);
- expect(this.collectionView.getChildView).to.have.been.calledWith(this.collection.models[1]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the docs are a bit vague but this might work...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but this does

      expect(this.collectionView.getChildView).to.have.been.calledTwice.
        and.calledWith(this.collection.models[0]).
        and.calledWith(this.collection.models[1]);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YESSS 👍

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 9ed8794 on cmaher:fix-1566 into 4b005b4 on marionettejs:v2.1.

@@ -1024,10 +1031,12 @@ describe('collection view', function() {

describe('when returning the view from addChild', function() {
beforeEach(function() {
this.model = new Backbone.Model({foo: 'bar'});
this.model = new Backbone.Model({foo: 'bar', view: this.ChildView });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of changing the existing test we should add another one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since getChildView is going to be called either way, should I just write an assertion for that instead?

Nevermind, ignore me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems weird to add it to the model though. Would this not be better:

- function(model) {
-   return model.get('view');
- }
+ sinon.stub().returns(this.view);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, not sure I like adding the view to the model

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 6dcb973 on cmaher:fix-1566 into 9abb5eb on marionettejs:v2.1.

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling cfd85ad on cmaher:fix-1566 into 9abb5eb on marionettejs:v2.1.

@jamesplease
Copy link
Member

👍

samccone added a commit that referenced this pull request Jul 14, 2014
Fix #1567 and add tests to cover getChildView taking a model
@samccone samccone merged commit 719b300 into marionettejs:v2.1 Jul 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants