Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 74afaef

Browse files
committed
test(config): always call the global onLoad handler
1 parent c83086a commit 74afaef

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

test/ace.spec.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)