From 3b5f1105f6fa615e0833502648c77d8878fd2c65 Mon Sep 17 00:00:00 2001
From: Igor Minar
Date: Fri, 10 Aug 2012 10:24:28 -0700
Subject: test(jqLite): add missing test for $destroy event
---
test/jqLiteSpec.js | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
(limited to 'test')
diff --git a/test/jqLiteSpec.js b/test/jqLiteSpec.js
index 406b7a5a..1a56a343 100644
--- a/test/jqLiteSpec.js
+++ b/test/jqLiteSpec.js
@@ -2,6 +2,9 @@
describe('jqLite', function() {
var scope, a, b, c;
+
+ beforeEach(module(provideLog));
+
beforeEach(function() {
a = jqLite('
A
')[0];
b = jqLite('B
')[0];
@@ -241,7 +244,7 @@ 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;';});
@@ -249,6 +252,18 @@ describe('jqLite', function() {
expect(log).toEqual('destroy;');
});
+
+ it('should emit $destroy event if an element is removed via html()', inject(function(log) {
+ var element = jqLite('x
');
+ 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({});
--
cgit v1.2.3