@@ -167,14 +167,37 @@ describe('uiAce', function () {
167167 } ) ;
168168 } ) ;
169169 describe ( 'onLoad' , function ( ) {
170- it ( 'runs the onLoad callback' , function ( ) {
171- scope . aceLoaded = function ( ) {
172- } ;
173- spyOn ( scope , 'aceLoaded' ) ;
170+ it ( 'should call the local onLoad callback' , function ( ) {
171+ scope . aceLoaded = jasmine . createSpy ( 'scope.aceLoaded' ) ;
174172 $compile ( '<div ui-ace="{onLoad: aceLoaded}">' ) ( scope ) ;
175173 expect ( scope . aceLoaded ) . toHaveBeenCalled ( ) ;
176174 expect ( scope . aceLoaded ) . toHaveBeenCalledWith ( _ace ) ;
177175 } ) ;
176+
177+ it ( 'should call the global onLoad callback' , function ( ) {
178+ uiConfig . ace . onLoad = jasmine . createSpy ( 'uiConfig.ace.onLoad' ) ;
179+ $compile ( '<div ui-ace>' ) ( scope ) ;
180+ expect ( uiConfig . ace . onLoad ) . toHaveBeenCalled ( ) ;
181+ expect ( uiConfig . ace . onLoad ) . toHaveBeenCalledWith ( _ace ) ;
182+ } ) ;
183+
184+ it ( 'should call both local/global onLoad callbacks' , function ( ) {
185+ scope . aceLoaded = jasmine . createSpy ( 'scope.aceLoaded' ) ;
186+ uiConfig . ace . onLoad = jasmine . createSpy ( 'uiConfig.ace.onLoad' ) ;
187+ $compile ( '<div ui-ace="{onLoad: aceLoaded}">' ) ( scope ) ;
188+ expect ( uiConfig . ace . onLoad ) . toHaveBeenCalled ( ) ;
189+ expect ( uiConfig . ace . onLoad ) . toHaveBeenCalledWith ( _ace ) ;
190+ expect ( scope . aceLoaded ) . toHaveBeenCalled ( ) ;
191+ expect ( scope . aceLoaded ) . toHaveBeenCalledWith ( _ace ) ;
192+ } ) ;
193+
194+ it ( 'should detect same local/global onLoad callback' , function ( ) {
195+ uiConfig . ace . onLoad = jasmine . createSpy ( 'uiConfig.ace.onLoad' ) ;
196+ scope . aceLoaded = uiConfig . ace . onLoad ;
197+ $compile ( '<div ui-ace="{onLoad: aceLoaded}">' ) ( scope ) ;
198+ expect ( uiConfig . ace . onLoad . calls . count ( ) ) . toBe ( 1 ) ;
199+ expect ( uiConfig . ace . onLoad ) . toHaveBeenCalledWith ( _ace ) ;
200+ } ) ;
178201 } ) ;
179202 } ) ;
180203
0 commit comments