fix/skip various SSR tests

pull/253/head
Rich Harris 8 years ago
parent c5e0e8aa63
commit 94aca91d35

@ -1,5 +1,5 @@
export default {
enter ( generator ) {
generator.append( `\${options.yield()}` );
generator.append( `\${options && options.yield ? options.yield() : ''}` );
}
};

@ -1,3 +1,3 @@
export default {
html: '<p>Hello</p>'
}
html: '<p>Hello</p>'
};

@ -1,15 +1,16 @@
<p>
Hello
{{#if test}}
{{yield}}
{{/if}}
Hello
{{#if test}}
{{yield}}
{{/if}}
</p>
<script>
export default {
data(){
return {
test: true
}
}
}
export default {
data () {
return {
test: true
};
}
};
</script>

@ -1,8 +1,12 @@
const ns = '<noscript></noscript>';
export default {
'skip-ssr': true,
data: {
raw: '<span><em>raw html!!!\\o/</span></em>'
},
html: `before${ns}<span><em>raw html!!!\\o/</span></em>${ns}after`,
test ( assert, component, target ) {

@ -1,4 +1,6 @@
export default {
'skip-ssr': true,
data: {
x: 0,
y: 0,

@ -1,7 +1,7 @@
import assert from 'assert';
import * as fs from 'fs';
import { exists, loadConfig, setupHtmlEqual, svelte, tryToLoadJson } from './helpers.js';
import { addLineNumbers, exists, loadConfig, setupHtmlEqual, svelte, tryToLoadJson } from './helpers.js';
function tryToReadFile ( file ) {
try {
@ -57,13 +57,15 @@ describe( 'ssr', () => {
if ( config.solo && process.env.CI ) {
throw new Error( 'Forgot to remove `solo: true` from test' );
}
if ( config['skip-ssr'] ) return;
( config.skip ? it.skip : config.solo ? it.only : it )( dir, () => {
let compiled;
try {
const source = fs.readFileSync( `test/generator/${dir}/main.html`, 'utf-8' );
svelte.compile( source, { generate: 'ssr' });
compiled = svelte.compile( source, { generate: 'ssr' });
} catch ( err ) {
if ( config.compileError ) {
config.compileError( err );
@ -74,11 +76,17 @@ describe( 'ssr', () => {
}
const component = require( `./generator/${dir}/main.html` );
let html;
const html = component.render( config.data );
try {
html = component.render( config.data );
if ( config.html ) {
assert.htmlEqual( html, config.html );
if ( config.html ) {
assert.htmlEqual( html, config.html );
}
} catch ( err ) {
console.log( addLineNumbers( compiled.code ) );
throw err;
}
});
});

Loading…
Cancel
Save