Skip to content

Commit

Permalink
minor test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Apr 6, 2017
1 parent b8705a5 commit 11033c2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
9 changes: 5 additions & 4 deletions test/runtime/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down Expand Up @@ -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 ) {
Expand Down Expand Up @@ -117,6 +118,8 @@ describe( 'generate', () => {
data: config.data
});

Object.assign = Object_assign;

console.warn = warn;

if ( config.error ) {
Expand All @@ -141,8 +144,6 @@ describe( 'generate', () => {
component.destroy();
assert.equal( target.innerHTML, '' );
}

Object.assign = Object_assign;
})
.catch( err => {
Object.assign = Object_assign;
Expand Down
6 changes: 5 additions & 1 deletion test/runtime/samples/attribute-dynamic-multiple/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>
`
};
18 changes: 15 additions & 3 deletions test/runtime/samples/each-block/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@ export default {
data: {
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 ) {
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: [] });
assert.equal( target.innerHTML, '<!---->' );
assert.htmlEqual( target.innerHTML, '' );
}
};

0 comments on commit 11033c2

Please sign in to comment.