mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 01:11:24 +01:00
minor test tweaks
This commit is contained in:
parent
b8705a5b0c
commit
11033c2f20
@ -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;
|
||||
|
@ -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: {
|
||||
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, '' );
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user