use component.destroy() in tests instead of component.teardown()

pull/316/head
Rich Harris 8 years ago
parent 1736498bde
commit d6962b3ff1

@ -17,7 +17,7 @@ function testAmd ( code, expectedId, dependencies, html ) {
assert.htmlEqual( main.innerHTML, html ); assert.htmlEqual( main.innerHTML, html );
component.teardown(); component.destroy();
} }
define.amd = true; define.amd = true;
@ -44,7 +44,7 @@ function testCjs ( code, dependencyById, html ) {
assert.htmlEqual( main.innerHTML, html ); assert.htmlEqual( main.innerHTML, html );
component.teardown(); component.destroy();
}); });
} }
@ -59,7 +59,7 @@ function testIife ( code, name, globals, html ) {
assert.htmlEqual( main.innerHTML, html ); assert.htmlEqual( main.innerHTML, html );
component.teardown(); component.destroy();
}); });
} }

@ -98,7 +98,7 @@ describe( 'generate', () => {
if ( config.test ) { if ( config.test ) {
config.test( assert, component, target, window ); config.test( assert, component, target, window );
} else { } else {
component.teardown(); component.destroy();
assert.equal( target.innerHTML, '' ); assert.equal( target.innerHTML, '' );
} }
}) })

@ -24,6 +24,6 @@ export default {
assert.equal( select.value, 'b' ); assert.equal( select.value, 'b' );
assert.ok( options[1].selected ); assert.ok( options[1].selected );
component.teardown(); component.destroy();
} }
}; };

@ -17,6 +17,6 @@ export default {
<p>blah, bar, baz</p> <p>blah, bar, baz</p>
` ); ` );
component.teardown(); component.destroy();
} }
}; };

@ -17,6 +17,6 @@ export default {
<p>blah, bar, baz</p> <p>blah, bar, baz</p>
` ); ` );
component.teardown(); component.destroy();
} }
}; };

@ -22,6 +22,6 @@ export default {
buttons[2].dispatchEvent( event ); buttons[2].dispatchEvent( event );
assert.deepEqual( clicks, [ 'a', 'c' ]); assert.deepEqual( clicks, [ 'a', 'c' ]);
component.teardown(); component.destroy();
} }
}; };

@ -7,6 +7,6 @@ export default {
component.set({ arriving: false }); component.set({ arriving: false });
assert.htmlEqual( target.innerHTML, `<div><p class='widget'>Goodbye</p></div>` ); assert.htmlEqual( target.innerHTML, `<div><p class='widget'>Goodbye</p></div>` );
component.teardown(); component.destroy();
} }
}; };

@ -4,6 +4,6 @@ export default {
test ( assert, component, target ) { test ( assert, component, target ) {
component.set({ a: 2 }); component.set({ a: 2 });
assert.equal( target.innerHTML, '<p>4</p>' ); assert.equal( target.innerHTML, '<p>4</p>' );
component.teardown(); component.destroy();
} }
}; };

@ -5,6 +5,6 @@ export default {
assert.equal( component.get( 'c' ), 5 ); assert.equal( component.get( 'c' ), 5 );
assert.equal( component.get( 'cSquared' ), 25 ); assert.equal( component.get( 'cSquared' ), 25 );
assert.equal( target.innerHTML, '<p>3 + 2 = 5</p>\n<p>5 * 5 = 25</p>' ); assert.equal( target.innerHTML, '<p>3 + 2 = 5</p>\n<p>5 * 5 = 25</p>' );
component.teardown(); component.destroy();
} }
}; };

@ -3,6 +3,6 @@ export default {
test ( assert, component ) { test ( assert, component ) {
assert.equal( component.get( 'foo' ), 'got' ); assert.equal( component.get( 'foo' ), 'got' );
component.teardown(); component.destroy();
} }
}; };

@ -22,6 +22,6 @@ export default {
assert.equal( count, 1 ); assert.equal( count, 1 );
assert.equal( number, 42 ); assert.equal( number, 42 );
component.teardown(); component.destroy();
} }
}; };

@ -23,6 +23,6 @@ export default {
assert.ok( !target.contains( p1 ), 'first <p> element should be removed' ); assert.ok( !target.contains( p1 ), 'first <p> element should be removed' );
assert.equal( p2, p3, 'second <p> element should be retained' ); assert.equal( p2, p3, 'second <p> element should be retained' );
component.teardown(); component.destroy();
} }
}; };

@ -12,6 +12,6 @@ export default {
component.fire( 'foo', expected ); component.fire( 'foo', expected );
assert.equal( count, 1 ); assert.equal( count, 1 );
component.teardown(); component.destroy();
} }
}; };

@ -7,7 +7,7 @@ export default {
count += 1; count += 1;
}); });
component.teardown(); component.destroy();
assert.equal( count, 1 ); assert.equal( count, 1 );
} }
}; };

@ -9,7 +9,7 @@ export default {
component.set({ name: 'everybody' }); component.set({ name: 'everybody' });
assert.htmlEqual( target.innerHTML, '<h1>Hello everybody!</h1>' ); assert.htmlEqual( target.innerHTML, '<h1>Hello everybody!</h1>' );
component.teardown(); component.destroy();
assert.htmlEqual( target.innerHTML, '' ); assert.htmlEqual( target.innerHTML, '' );
} }
}; };

@ -18,6 +18,6 @@ export default {
before-else-after before-else-after
` ); ` );
component.teardown(); component.destroy();
} }
}; };

@ -18,6 +18,6 @@ export default {
<p>x is between 5 and 10</p> <p>x is between 5 and 10</p>
` ); ` );
component.teardown(); component.destroy();
} }
}; };

@ -1,7 +1,7 @@
export default { export default {
test ( assert, component ) { test ( assert, component ) {
assert.deepEqual( component.events, [ 'render' ]); assert.deepEqual( component.events, [ 'render' ]);
component.teardown(); component.destroy();
assert.deepEqual( component.events, [ 'render', 'teardown' ]); assert.deepEqual( component.events, [ 'render', 'teardown' ]);
} }
}; };

@ -12,6 +12,6 @@ export default {
<span>1</span><span>2</span><span>3</span><span>4</span><span>5</span> <span>1</span><span>2</span><span>3</span><span>4</span><span>5</span>
` ); ` );
component.teardown(); component.destroy();
} }
}; };

@ -7,6 +7,6 @@ export default {
component.set({ foo: true }); component.set({ foo: true });
assert.htmlEqual( target.innerHTML, `<div><p>true</p>\n<p>true</p></div>` ); assert.htmlEqual( target.innerHTML, `<div><p>true</p>\n<p>true</p></div>` );
component.teardown(); component.destroy();
} }
}; };

@ -16,6 +16,6 @@ export default {
assert.equal( target.innerHTML, `<div>${ns}<p>does not change</p>${ns}</div>` ); assert.equal( target.innerHTML, `<div>${ns}<p>does not change</p>${ns}</div>` );
assert.strictEqual( target.querySelector( 'p' ), p ); assert.strictEqual( target.querySelector( 'p' ), p );
component.teardown(); component.destroy();
} }
}; };

@ -14,7 +14,7 @@ export default {
assert.equal( target.innerHTML, `before${ns}${ns}after` ); assert.equal( target.innerHTML, `before${ns}${ns}after` );
component.set({ raw: 'how about <strong>unclosed elements?' }); component.set({ raw: 'how about <strong>unclosed elements?' });
assert.equal( target.innerHTML, `before${ns}how about <strong>unclosed elements?</strong>${ns}after` ); assert.equal( target.innerHTML, `before${ns}how about <strong>unclosed elements?</strong>${ns}after` );
component.teardown(); component.destroy();
assert.equal( target.innerHTML, '' ); assert.equal( target.innerHTML, '' );
} }
}; };

@ -25,7 +25,7 @@ export default {
assert.equal( target.querySelector( 'select' ).value, 'a' ); assert.equal( target.querySelector( 'select' ).value, 'a' );
component.teardown(); component.destroy();
assert.htmlEqual( target.innerHTML, '' ); assert.htmlEqual( target.innerHTML, '' );
} }
}; };

@ -3,6 +3,6 @@ export default {
test ( assert, component ) { test ( assert, component ) {
component.set({ foo: { x: 2 } }); component.set({ foo: { x: 2 } });
component.teardown(); component.destroy();
} }
}; };

@ -10,6 +10,6 @@ export default {
test ( assert, component, target ) { test ( assert, component, target ) {
const circle = target.querySelector( 'circle' ); const circle = target.querySelector( 'circle' );
assert.equal( circle.getAttribute( 'class' ), 'red' ); assert.equal( circle.getAttribute( 'class' ), 'red' );
component.teardown(); component.destroy();
} }
}; };

@ -9,6 +9,6 @@ export default {
assert.equal( svg.namespaceURI, 'http://www.w3.org/2000/svg' ); assert.equal( svg.namespaceURI, 'http://www.w3.org/2000/svg' );
assert.equal( svg.getAttribute( 'class' ), 'foo' ); assert.equal( svg.getAttribute( 'class' ), 'foo' );
component.teardown(); component.destroy();
} }
}; };

@ -10,6 +10,6 @@ export default {
assert.equal( circles[0].namespaceURI, 'http://www.w3.org/2000/svg' ); assert.equal( circles[0].namespaceURI, 'http://www.w3.org/2000/svg' );
assert.equal( circles[1].namespaceURI, 'http://www.w3.org/2000/svg' ); assert.equal( circles[1].namespaceURI, 'http://www.w3.org/2000/svg' );
assert.equal( circles[2].namespaceURI, 'http://www.w3.org/2000/svg' ); assert.equal( circles[2].namespaceURI, 'http://www.w3.org/2000/svg' );
component.teardown(); component.destroy();
} }
}; };

@ -14,6 +14,6 @@ export default {
assert.equal( href.namespaceURI, 'http://www.w3.org/1999/xlink' ); assert.equal( href.namespaceURI, 'http://www.w3.org/1999/xlink' );
component.teardown(); component.destroy();
} }
}; };

Loading…
Cancel
Save