Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

feat(modal): Switched the modal transclude to use $animate #6029

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,16 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.p
};
})

.directive('uibModalTransclude', function() {
.directive('uibModalTransclude', ['$animate', function($animate) {
return {
link: function(scope, element, attrs, controller, transclude) {
transclude(scope.$parent, function(clone) {
element.empty();
element.append(clone);
$animate.enter(clone, element);
});
}
};
})
}])

.factory('$uibModalStack', ['$animate', '$animateCss', '$document',
'$compile', '$rootScope', '$q', '$$multiMap', '$$stackedMap', '$uibPosition',
Expand Down
56 changes: 56 additions & 0 deletions src/modal/test/modal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,62 @@ describe('$uibResolve', function() {
});
});

describe('uibModalTransclude', function() {
var uibModalTranscludeDDO,
$animate;

beforeEach(module('ui.bootstrap.modal'));
beforeEach(module(function($provide) {
$animate = jasmine.createSpyObj('$animate', ['enter']);
$provide.value('$animate', $animate);
}));

beforeEach(inject(function(uibModalTranscludeDirective) {
uibModalTranscludeDDO = uibModalTranscludeDirective[0];
}));

describe('when initialised', function() {
var scope,
element,
transcludeSpy,
transcludeFn;

beforeEach(function() {
scope = {
$parent: 'parentScope'
};

element = jasmine.createSpyObj('containerElement', ['empty']);
transcludeSpy = jasmine.createSpy('transcludeSpy').and.callFake(function(scope, fn) {
transcludeFn = fn;
});

uibModalTranscludeDDO.link(scope, element, {}, {}, transcludeSpy);
});

it('should call the transclusion function', function() {
expect(transcludeSpy).toHaveBeenCalledWith(scope.$parent, jasmine.any(Function));
});

describe('transclusion callback', function() {
var transcludedContent;

beforeEach(function() {
transcludedContent = 'my transcluded content';
transcludeFn(transcludedContent);
});

it('should empty the element', function() {
expect(element.empty).toHaveBeenCalledWith();
});

it('should append the transcluded content', function() {
expect($animate.enter).toHaveBeenCalledWith(transcludedContent, element);
});
});
});
});

describe('$uibModal', function() {
var $animate, $controllerProvider, $rootScope, $document, $compile, $templateCache, $timeout, $q;
var $uibModal, $uibModalStack, $uibModalProvider;
Expand Down