mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
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:
@@ -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');
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user