This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change 2
2
describe ( 'jqLite' , function ( ) {
3
3
var scope , a , b , c ;
4
4
5
+
6
+ beforeEach ( module ( provideLog ) ) ;
7
+
5
8
beforeEach ( function ( ) {
6
9
a = jqLite ( '<div>A</div>' ) [ 0 ] ;
7
10
b = jqLite ( '<div>B</div>' ) [ 0 ] ;
@@ -241,14 +244,26 @@ describe('jqLite', function() {
241
244
expect ( jqLite ( c ) . data ( 'prop' ) ) . toBeUndefined ( ) ;
242
245
} ) ;
243
246
244
- it ( 'should call $destroy function if element removed' , function ( ) {
247
+ it ( 'should emit $destroy event if element removed via remove() ' , function ( ) {
245
248
var log = '' ;
246
249
var element = jqLite ( a ) ;
247
250
element . bind ( '$destroy' , function ( ) { log += 'destroy;' ; } ) ;
248
251
element . remove ( ) ;
249
252
expect ( log ) . toEqual ( 'destroy;' ) ;
250
253
} ) ;
251
254
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
+
252
267
it ( 'should retrieve all data if called without params' , function ( ) {
253
268
var element = jqLite ( a ) ;
254
269
expect ( element . data ( ) ) . toEqual ( { } ) ;
You can’t perform that action at this time.
0 commit comments