minor test tweaks

pull/453/head
Rich Harris 8 years ago
parent b8705a5b0c
commit 11033c2f20

@ -32,7 +32,7 @@ require.extensions[ '.html' ] = function ( module, filename ) {
const Object_assign = Object.assign; const Object_assign = Object.assign;
describe( 'generate', () => { describe( 'runtime', () => {
before( setupHtmlEqual ); before( setupHtmlEqual );
function runTest ( dir, shared ) { function runTest ( dir, shared ) {
@ -69,7 +69,8 @@ describe( 'generate', () => {
// check that no ES2015+ syntax slipped in // check that no ES2015+ syntax slipped in
if ( !config.allowES2015 ) { if ( !config.allowES2015 ) {
try { try {
const startIndex = code.indexOf( 'function render_main_fragment' ); // may change! const startIndex = code.indexOf( 'function create_main_fragment' ); // may change!
if ( startIndex === -1 ) throw new Error( 'missing create_main_fragment' );
const es5 = spaces( startIndex ) + code.slice( startIndex ).replace( /export default .+/, '' ); const es5 = spaces( startIndex ) + code.slice( startIndex ).replace( /export default .+/, '' );
acorn.parse( es5, { ecmaVersion: 5 }); acorn.parse( es5, { ecmaVersion: 5 });
} catch ( err ) { } catch ( err ) {
@ -117,6 +118,8 @@ describe( 'generate', () => {
data: config.data data: config.data
}); });
Object.assign = Object_assign;
console.warn = warn; console.warn = warn;
if ( config.error ) { if ( config.error ) {
@ -141,8 +144,6 @@ describe( 'generate', () => {
component.destroy(); component.destroy();
assert.equal( target.innerHTML, '' ); assert.equal( target.innerHTML, '' );
} }
Object.assign = Object_assign;
}) })
.catch( err => { .catch( err => {
Object.assign = Object_assign; Object.assign = Object_assign;

@ -7,5 +7,9 @@ export default {
] ]
}, },
html: `<div class="foo ">1</div><div class=" bar">2</div><div class="foo bar">3</div><!---->` html: `
<div class="foo ">1</div>
<div class=" bar">2</div>
<div class="foo bar">3</div>
`
}; };

@ -2,11 +2,23 @@ export default {
data: { data: {
animals: [ 'alpaca', 'baboon', 'capybara' ] animals: [ 'alpaca', 'baboon', 'capybara' ]
}, },
html: '<p>alpaca</p><p>baboon</p><p>capybara</p><!---->',
html: `
<p>alpaca</p>
<p>baboon</p>
<p>capybara</p>
`,
test ( assert, component, target ) { test ( assert, component, target ) {
component.set({ animals: [ 'alpaca', 'baboon', 'caribou', 'dogfish' ] }); component.set({ animals: [ 'alpaca', 'baboon', 'caribou', 'dogfish' ] });
assert.equal( target.innerHTML, '<p>alpaca</p><p>baboon</p><p>caribou</p><p>dogfish</p><!---->' ); assert.htmlEqual( target.innerHTML, `
<p>alpaca</p>
<p>baboon</p>
<p>caribou</p>
<p>dogfish</p>
` );
component.set({ animals: [] }); component.set({ animals: [] });
assert.equal( target.innerHTML, '<!---->' ); assert.htmlEqual( target.innerHTML, '' );
} }
}; };

Loading…
Cancel
Save