@@ -350,6 +350,49 @@ describe('UNIT: API', function () {
350350
351351 } )
352352
353+ describe ( 'replace' , function ( ) {
354+
355+ it ( 'should replace an in DOM node' , function ( ) {
356+ var testId = 'replace-test'
357+ mock ( testId , '<div>ho</div>' )
358+ var old = document . getElementById ( testId ) ,
359+ parent = old . parentNode
360+ var Test = Seed . extend ( {
361+ template : '<p>hi</p>' ,
362+ replace : true
363+ } )
364+ var t = new Test ( {
365+ el : '#' + testId
366+ } )
367+ assert . strictEqual ( t . $el . tagName , 'P' )
368+ assert . strictEqual ( t . $el . textContent , 'hi' )
369+ assert . strictEqual ( t . $el . parentNode , parent )
370+ var now = document . getElementById ( testId )
371+ assert . strictEqual ( now , null )
372+ } )
373+
374+ it ( 'should replace an off DOM Seed\'s $el' , function ( ) {
375+ var Test = Seed . extend ( {
376+ template : '<p>hi</p>' ,
377+ replace : true
378+ } )
379+ var t = new Test ( )
380+ assert . strictEqual ( t . $el . tagName , 'P' )
381+ assert . strictEqual ( t . $el . textContent , 'hi' )
382+ } )
383+
384+ it ( 'should not work if template has more than one child node' , function ( ) {
385+ var Test = Seed . extend ( {
386+ template : '<p>hi</p><p>ho</p>' ,
387+ replace : true
388+ } )
389+ var t = new Test ( )
390+ assert . notStrictEqual ( t . $el . tagName , 'P' )
391+ assert . strictEqual ( t . $el . innerHTML , '<p>hi</p><p>ho</p>' )
392+ } )
393+
394+ } )
395+
353396 describe ( 'element options' , function ( ) {
354397
355398 it ( 'should not accept el as an extension option' , function ( ) {
0 commit comments