mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-27 06:54:01 +00:00
test(jqLite): add missing test for $destroy event
This commit is contained in:
parent
663ccc5449
commit
3b5f1105f6
1 changed files with 16 additions and 1 deletions
|
|
@ -2,6 +2,9 @@
|
||||||
describe('jqLite', function() {
|
describe('jqLite', function() {
|
||||||
var scope, a, b, c;
|
var scope, a, b, c;
|
||||||
|
|
||||||
|
|
||||||
|
beforeEach(module(provideLog));
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
a = jqLite('<div>A</div>')[0];
|
a = jqLite('<div>A</div>')[0];
|
||||||
b = jqLite('<div>B</div>')[0];
|
b = jqLite('<div>B</div>')[0];
|
||||||
|
|
@ -241,7 +244,7 @@ describe('jqLite', function() {
|
||||||
expect(jqLite(c).data('prop')).toBeUndefined();
|
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 log = '';
|
||||||
var element = jqLite(a);
|
var element = jqLite(a);
|
||||||
element.bind('$destroy', function() {log+= 'destroy;';});
|
element.bind('$destroy', function() {log+= 'destroy;';});
|
||||||
|
|
@ -249,6 +252,18 @@ describe('jqLite', function() {
|
||||||
expect(log).toEqual('destroy;');
|
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() {
|
it('should retrieve all data if called without params', function() {
|
||||||
var element = jqLite(a);
|
var element = jqLite(a);
|
||||||
expect(element.data()).toEqual({});
|
expect(element.data()).toEqual({});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue