pull/31/head
Rich-Harris 8 years ago
parent c205761fe1
commit 1fcaf01566

@ -7,7 +7,7 @@ import jsdom from 'jsdom';
const cache = {}; const cache = {};
require.extensions[ '.svelte' ] = function ( module, filename ) { require.extensions[ '.html' ] = function ( module, filename ) {
const code = cache[ filename ]; const code = cache[ filename ];
if ( !code ) throw new Error( `not compiled: ${filename}` ); if ( !code ) throw new Error( `not compiled: ${filename}` );
@ -31,7 +31,7 @@ describe( 'svelte', () => {
const solo = exists( `test/parser/${dir}/solo` ); const solo = exists( `test/parser/${dir}/solo` );
( solo ? it.only : it )( dir, () => { ( solo ? it.only : it )( dir, () => {
const input = fs.readFileSync( `test/parser/${dir}/input.svelte`, 'utf-8' ).trim(); const input = fs.readFileSync( `test/parser/${dir}/input.html`, 'utf-8' ).trim();
const actual = parse( input ); const actual = parse( input );
const expected = require( `./parser/${dir}/output.json` ); const expected = require( `./parser/${dir}/output.json` );
@ -75,7 +75,7 @@ describe( 'svelte', () => {
let compiled; let compiled;
try { try {
const source = fs.readFileSync( `test/compiler/${dir}/main.svelte`, 'utf-8' ); const source = fs.readFileSync( `test/compiler/${dir}/main.html`, 'utf-8' );
compiled = compile( source ); compiled = compile( source );
} catch ( err ) { } catch ( err ) {
if ( config.compileError ) { if ( config.compileError ) {
@ -94,12 +94,12 @@ describe( 'svelte', () => {
return `${i}: ${line.replace( /^\t+/, match => match.split( '\t' ).join( ' ' ) )}`; return `${i}: ${line.replace( /^\t+/, match => match.split( '\t' ).join( ' ' ) )}`;
}).join( '\n' ); }).join( '\n' );
cache[ path.resolve( `test/compiler/${dir}/main.svelte` ) ] = code; cache[ path.resolve( `test/compiler/${dir}/main.html` ) ] = code;
let factory; let factory;
try { try {
factory = require( `./compiler/${dir}/main.svelte` ).default; factory = require( `./compiler/${dir}/main.html` ).default;
} catch ( err ) { } catch ( err ) {
console.log( withLineNumbers ); // eslint-disable-line no-console console.log( withLineNumbers ); // eslint-disable-line no-console
throw err; throw err;

Loading…
Cancel
Save