Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit c0d638a

Browse files
committed
test(jqLite): add missing test for $destroy event
1 parent 054d40f commit c0d638a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/jqLiteSpec.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
describe('jqLite', function() {
33
var scope, a, b, c;
44

5+
6+
beforeEach(module(provideLog));
7+
58
beforeEach(function() {
69
a = jqLite('<div>A</div>')[0];
710
b = jqLite('<div>B</div>')[0];
@@ -241,14 +244,26 @@ describe('jqLite', function() {
241244
expect(jqLite(c).data('prop')).toBeUndefined();
242245
});
243246

244-
it('should call $destroy function if element removed', function() {
247+
it('should emit $destroy event if element removed via remove()', function() {
245248
var log = '';
246249
var element = jqLite(a);
247250
element.bind('$destroy', function() {log+= 'destroy;';});
248251
element.remove();
249252
expect(log).toEqual('destroy;');
250253
});
251254

255+
256+
it('should emit $destroy event if an element is removed via html()', inject(function(log) {
257+
var element = jqLite('<div><span>x</span></div>');
258+
element.find('span').bind('$destroy', log.fn('destroyed'));
259+
260+
element.html('');
261+
262+
expect(element.html()).toBe('');
263+
expect(log).toEqual('destroyed');
264+
}));
265+
266+
252267
it('should retrieve all data if called without params', function() {
253268
var element = jqLite(a);
254269
expect(element.data()).toEqual({});

0 commit comments

Comments
 (0)