From 11033c2f20c27f7bb713cfa7d7f65812dc276334 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 6 Apr 2017 15:45:26 -0400 Subject: [PATCH] minor test tweaks --- test/runtime/index.js | 9 +++++---- .../attribute-dynamic-multiple/_config.js | 6 +++++- test/runtime/samples/each-block/_config.js | 18 +++++++++++++++--- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/test/runtime/index.js b/test/runtime/index.js index 0d74c6db45..780e380caf 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -32,7 +32,7 @@ require.extensions[ '.html' ] = function ( module, filename ) { const Object_assign = Object.assign; -describe( 'generate', () => { +describe( 'runtime', () => { before( setupHtmlEqual ); function runTest ( dir, shared ) { @@ -69,7 +69,8 @@ describe( 'generate', () => { // check that no ES2015+ syntax slipped in if ( !config.allowES2015 ) { 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 .+/, '' ); acorn.parse( es5, { ecmaVersion: 5 }); } catch ( err ) { @@ -117,6 +118,8 @@ describe( 'generate', () => { data: config.data }); + Object.assign = Object_assign; + console.warn = warn; if ( config.error ) { @@ -141,8 +144,6 @@ describe( 'generate', () => { component.destroy(); assert.equal( target.innerHTML, '' ); } - - Object.assign = Object_assign; }) .catch( err => { Object.assign = Object_assign; diff --git a/test/runtime/samples/attribute-dynamic-multiple/_config.js b/test/runtime/samples/attribute-dynamic-multiple/_config.js index 1a0c602cb6..048c5130e5 100644 --- a/test/runtime/samples/attribute-dynamic-multiple/_config.js +++ b/test/runtime/samples/attribute-dynamic-multiple/_config.js @@ -7,5 +7,9 @@ export default { ] }, - html: `
1
2
3
` + html: ` +
1
+
2
+
3
+ ` }; diff --git a/test/runtime/samples/each-block/_config.js b/test/runtime/samples/each-block/_config.js index 655556bedf..73e3d0c6f4 100644 --- a/test/runtime/samples/each-block/_config.js +++ b/test/runtime/samples/each-block/_config.js @@ -2,11 +2,23 @@ export default { data: { animals: [ 'alpaca', 'baboon', 'capybara' ] }, - html: '

alpaca

baboon

capybara

', + + html: ` +

alpaca

+

baboon

+

capybara

+ `, + test ( assert, component, target ) { component.set({ animals: [ 'alpaca', 'baboon', 'caribou', 'dogfish' ] }); - assert.equal( target.innerHTML, '

alpaca

baboon

caribou

dogfish

' ); + assert.htmlEqual( target.innerHTML, ` +

alpaca

+

baboon

+

caribou

+

dogfish

+ ` ); + component.set({ animals: [] }); - assert.equal( target.innerHTML, '' ); + assert.htmlEqual( target.innerHTML, '' ); } };