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

Commit

Permalink
test(jqLite): add missing test for $destroy event
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorMinar committed Aug 10, 2012
1 parent 054d40f commit c0d638a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
describe('jqLite', function() {
var scope, a, b, c;


beforeEach(module(provideLog));

beforeEach(function() {
a = jqLite('<div>A</div>')[0];
b = jqLite('<div>B</div>')[0];
Expand Down Expand Up @@ -241,14 +244,26 @@ describe('jqLite', function() {
expect(jqLite(c).data('prop')).toBeUndefined();
});

it('should call $destroy function if element removed', function() {
it('should emit $destroy event if element removed via remove()', function() {
var log = '';
var element = jqLite(a);
element.bind('$destroy', function() {log+= 'destroy;';});
element.remove();
expect(log).toEqual('destroy;');
});


it('should emit $destroy event if an element is removed via html()', inject(function(log) {
var element = jqLite('<div><span>x</span></div>');
element.find('span').bind('$destroy', log.fn('destroyed'));

element.html('');

expect(element.html()).toBe('');
expect(log).toEqual('destroyed');
}));


it('should retrieve all data if called without params', function() {
var element = jqLite(a);
expect(element.data()).toEqual({});
Expand Down

0 comments on commit c0d638a

Please sign in to comment.