@@ -46,6 +46,62 @@ describe('$uibResolve', function() {
46
46
} ) ;
47
47
} ) ;
48
48
49
+ describe ( 'uibModalTransclude' , function ( ) {
50
+ var uibModalTranscludeDDO ,
51
+ $animate ;
52
+
53
+ beforeEach ( module ( 'ui.bootstrap.modal' ) ) ;
54
+ beforeEach ( module ( function ( $provide ) {
55
+ $animate = jasmine . createSpyObj ( '$animate' , [ 'enter' ] ) ;
56
+ $provide . value ( '$animate' , $animate ) ;
57
+ } ) ) ;
58
+
59
+ beforeEach ( inject ( function ( uibModalTranscludeDirective ) {
60
+ uibModalTranscludeDDO = uibModalTranscludeDirective [ 0 ] ;
61
+ } ) ) ;
62
+
63
+ describe ( 'when initialised' , function ( ) {
64
+ var scope ,
65
+ element ,
66
+ transcludeSpy ,
67
+ transcludeFn ;
68
+
69
+ beforeEach ( function ( ) {
70
+ scope = {
71
+ $parent : 'parentScope'
72
+ } ;
73
+
74
+ element = jasmine . createSpyObj ( 'containerElement' , [ 'empty' ] ) ;
75
+ transcludeSpy = jasmine . createSpy ( 'transcludeSpy' ) . and . callFake ( function ( scope , fn ) {
76
+ transcludeFn = fn ;
77
+ } ) ;
78
+
79
+ uibModalTranscludeDDO . link ( scope , element , { } , { } , transcludeSpy ) ;
80
+ } ) ;
81
+
82
+ it ( 'should call the transclusion function' , function ( ) {
83
+ expect ( transcludeSpy ) . toHaveBeenCalledWith ( scope . $parent , jasmine . any ( Function ) ) ;
84
+ } ) ;
85
+
86
+ describe ( 'transclusion callback' , function ( ) {
87
+ var transcludedContent ;
88
+
89
+ beforeEach ( function ( ) {
90
+ transcludedContent = 'my transcluded content' ;
91
+ transcludeFn ( transcludedContent ) ;
92
+ } ) ;
93
+
94
+ it ( 'should empty the element' , function ( ) {
95
+ expect ( element . empty ) . toHaveBeenCalledWith ( ) ;
96
+ } ) ;
97
+
98
+ it ( 'should append the transcluded content' , function ( ) {
99
+ expect ( $animate . enter ) . toHaveBeenCalledWith ( transcludedContent , element ) ;
100
+ } ) ;
101
+ } ) ;
102
+ } ) ;
103
+ } ) ;
104
+
49
105
describe ( '$uibModal' , function ( ) {
50
106
var $animate , $controllerProvider , $rootScope , $document , $compile , $templateCache , $timeout , $q ;
51
107
var $uibModal , $uibModalStack , $uibModalProvider ;
0 commit comments