refactor(modal): trigger resize event on the window when modal opens

A better approach to resolving an issue with collection-repeat sizing itself properly. This keeps directives independent of eachother.
This commit is contained in:
Perry Govier
2014-07-24 14:45:40 -05:00
parent 1fbd3c5632
commit 4f6d02cfcb
4 changed files with 9 additions and 23 deletions

View File

@@ -152,24 +152,6 @@ describe('collectionRepeat directive', function() {
expect(scrollView.resize.callCount).toBe(1);
});
it('should rerender on modal popup', function() {
inject(function($rootScope) {
var el = setup('collection-repeat="item in items" collection-item-height="50"');
var scrollView = el.controller('$ionicScroll').scrollView;
spyOn(scrollView, 'resize');
dataSource.setData.reset();
repeatManager.resize.reset();
el.scope().items = [1, 2, 3];
$rootScope.$broadcast('modal.shown');
expect(dataSource.setData).toHaveBeenCalledWith(el.scope().items);
expect(repeatManager.resize.callCount).toBe(1);
expect(scrollView.resize.callCount).toBe(1);
});
});
it('$destroy', function() {
var el = setup('collection-repeat="item in items" collection-item-height="50"');
dataSource.destroy = jasmine.createSpy('dataSourceDestroy');

View File

@@ -48,6 +48,14 @@ describe('Ionic Modal', function() {
expect(instance.isShown()).toBe(false);
});
it('should trigger a resize event', function() {
var instance = modal.fromTemplate('<div class="modal">hello</div>');
spyOn(ionic, 'trigger');
instance.show();
timeout.flush();
expect(ionic.trigger).toHaveBeenCalledWith('resize');
});
it('should set isShown on remove', function() {
var instance = modal.fromTemplate('<div class="modal">hello</div>');
expect(instance.isShown()).toBe(false);