|
|
|
@ -1,3 +1,5 @@
|
|
|
|
|
var PaginationModel = require('../../../../../javascripts/cartodb/new_common/views/pagination/model');
|
|
|
|
|
var PaginationView = require('../../../../../javascripts/cartodb/new_common/views/pagination/view');
|
|
|
|
|
var ContentFooterView = require('../../../../../javascripts/cartodb/new_dashboard/content_footer/view');
|
|
|
|
|
var cdb = require('cartodb.js');
|
|
|
|
|
var Router = require('../../../../../javascripts/cartodb/new_dashboard/router');
|
|
|
|
@ -19,23 +21,19 @@ describe('new_dashboard/content_footer/view', function() {
|
|
|
|
|
|
|
|
|
|
spyOn(this.router.model, 'bind').and.callThrough();
|
|
|
|
|
|
|
|
|
|
this.paginationModelStub = jasmine.createSpyObj('paginationModel', ['render', 'clean', 'set']);
|
|
|
|
|
this.PaginationModelSpy = jasmine.createSpy('PaginationModel');
|
|
|
|
|
this.PaginationModelSpy.and.returnValue(this.paginationModelStub);
|
|
|
|
|
ContentFooterView.__set__('PaginationModel', this.PaginationModelSpy);
|
|
|
|
|
spyOn(PaginationModel.prototype, 'initialize').and.callThrough();
|
|
|
|
|
spyOn(PaginationModel.prototype, 'set').and.callThrough();
|
|
|
|
|
|
|
|
|
|
this.paginationViewStub = jasmine.createSpyObj('paginationView', ['render', 'clean']);
|
|
|
|
|
this.paginationViewStub.el = $('<div class="Pagination"></div>')[0];
|
|
|
|
|
this.PaginationViewSpy = jasmine.createSpy('PaginationView');
|
|
|
|
|
this.PaginationViewSpy.and.returnValue(this.paginationViewStub);
|
|
|
|
|
ContentFooterView.__set__('PaginationView', this.PaginationViewSpy);
|
|
|
|
|
spyOn(PaginationView.prototype, 'initialize').and.callThrough();
|
|
|
|
|
spyOn(PaginationView.prototype, 'render').and.callThrough();
|
|
|
|
|
spyOn(PaginationView.prototype, 'clean').and.callThrough();
|
|
|
|
|
|
|
|
|
|
this.view = new ContentFooterView({
|
|
|
|
|
el: $el[0],
|
|
|
|
|
collection: this.collection,
|
|
|
|
|
router: this.router
|
|
|
|
|
});
|
|
|
|
|
spyOn(this.view, 'clearSubViews');
|
|
|
|
|
spyOn(this.view, 'clearSubViews').and.callThrough();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should listen to change events on router model', function() {
|
|
|
|
@ -44,19 +42,19 @@ describe('new_dashboard/content_footer/view', function() {
|
|
|
|
|
|
|
|
|
|
describe('should create a pagination view', function() {
|
|
|
|
|
it('with a pagination model args', function() {
|
|
|
|
|
expect(this.PaginationViewSpy).toHaveBeenCalled();
|
|
|
|
|
expect(PaginationView.prototype.initialize).toHaveBeenCalled();
|
|
|
|
|
|
|
|
|
|
var createdWith = this.PaginationViewSpy.calls.argsFor(0)[0];
|
|
|
|
|
expect(createdWith).toEqual(jasmine.objectContaining({ model: this.paginationModelStub }));
|
|
|
|
|
var createdWith = PaginationView.prototype.initialize.calls.argsFor(0)[0];
|
|
|
|
|
expect(createdWith).toEqual(jasmine.objectContaining({ model: jasmine.any(Object) }));
|
|
|
|
|
expect(createdWith).toEqual(jasmine.objectContaining({ router: this.router }));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('but not render just yet', function() {
|
|
|
|
|
expect(this.paginationViewStub.render).not.toHaveBeenCalled();
|
|
|
|
|
expect(PaginationView.prototype.render).not.toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('which model should be initially configured for routing', function() {
|
|
|
|
|
var viewmodelCreatedWith = this.PaginationModelSpy.calls.argsFor(0)[0];
|
|
|
|
|
var viewmodelCreatedWith = PaginationModel.prototype.initialize.calls.argsFor(0)[0];
|
|
|
|
|
expect(viewmodelCreatedWith).toEqual(jasmine.objectContaining({ current_page: jasmine.any(Number) }));
|
|
|
|
|
expect(viewmodelCreatedWith).toEqual(jasmine.objectContaining({ url_to: jasmine.any(Function) }));
|
|
|
|
|
});
|
|
|
|
@ -71,8 +69,8 @@ describe('new_dashboard/content_footer/view', function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should update the pagination model accordingly', function() {
|
|
|
|
|
expect(this.paginationModelStub.set).toHaveBeenCalledWith(jasmine.objectContaining({ per_page: this.collection.options.get('per_page') }));
|
|
|
|
|
expect(this.paginationModelStub.set).toHaveBeenCalledWith(jasmine.objectContaining({ total_count: this.collection.total_entries }));
|
|
|
|
|
expect(PaginationModel.prototype.set).toHaveBeenCalledWith(jasmine.objectContaining({ per_page: this.collection.options.get('per_page') }));
|
|
|
|
|
expect(PaginationModel.prototype.set).toHaveBeenCalledWith(jasmine.objectContaining({ total_count: this.collection.total_entries }));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
@ -83,7 +81,7 @@ describe('new_dashboard/content_footer/view', function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should update the pagination model accordingly', function() {
|
|
|
|
|
expect(this.paginationModelStub.set).toHaveBeenCalledWith('current_page', this.router.model.get('page'));
|
|
|
|
|
expect(PaginationModel.prototype.set).toHaveBeenCalledWith('current_page', this.router.model.get('page'));
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -102,7 +100,7 @@ describe('new_dashboard/content_footer/view', function() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should render pagination view', function() {
|
|
|
|
|
expect(this.paginationViewStub.render).toHaveBeenCalled();
|
|
|
|
|
expect(PaginationView.prototype.render).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should append the PaginationView to this el', function() {
|
|
|
|
|