|
1 | 1 | var should = require('chai').should(), |
2 | 2 | sinon = require('sinon'), |
| 3 | + _ = require('underscore'), |
3 | 4 | BaseModel = require('../../../shared/base/model'), |
4 | 5 | BaseCollection = require('../../../shared/base/collection'), |
5 | 6 | BaseView = require('../../../shared/base/view'), |
@@ -37,6 +38,37 @@ describe('BaseView', function() { |
37 | 38 | childViews.should.have.length(2); |
38 | 39 | }); |
39 | 40 |
|
| 41 | + describe('constructor', function() { |
| 42 | + var spy, data, view; |
| 43 | + |
| 44 | + beforeEach(function() { |
| 45 | + spy = sinon.spy(Backbone, 'View'); |
| 46 | + data = { app: this.app, el: '#test' }; |
| 47 | + }); |
| 48 | + |
| 49 | + afterEach(function() { |
| 50 | + Backbone.View.restore(); |
| 51 | + }) |
| 52 | + |
| 53 | + it('does not pass the model if it is set', function() { |
| 54 | + data.model = 'a' |
| 55 | + view = new BaseView(data) |
| 56 | + |
| 57 | + spy.should.have.been.called |
| 58 | + spy.should.have.been.calledWith(_.omit(data, 'model')) |
| 59 | + view.model.should.equal(data.model) |
| 60 | + }); |
| 61 | + |
| 62 | + it('does not pass the collection if it is set', function() { |
| 63 | + data.collection = 'a' |
| 64 | + view = new BaseView(data) |
| 65 | + |
| 66 | + spy.should.have.been.called |
| 67 | + spy.should.have.been.calledWith(_.omit(data, 'collection')) |
| 68 | + view.collection.should.equal(data.collection) |
| 69 | + }); |
| 70 | + }); |
| 71 | + |
40 | 72 | describe('getTemplate', function() { |
41 | 73 | beforeEach(function() { |
42 | 74 | this.app = { |
|
0 commit comments