mirror of https://github.com/sveltejs/svelte
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
846 B
41 lines
846 B
8 years ago
|
import deindent from '../../src/utils/deindent.js';
|
||
8 years ago
|
import assert from 'assert';
|
||
8 years ago
|
import { svelte } from '../helpers.js';
|
||
8 years ago
|
|
||
|
describe( 'create', () => {
|
||
|
it( 'should return a component constructor', () => {
|
||
|
const source = deindent`
|
||
|
<div>{{prop}}</div>
|
||
|
`;
|
||
|
|
||
|
const component = svelte.create( source );
|
||
|
assert( component instanceof Function );
|
||
|
});
|
||
|
|
||
|
it( 'should throw error when source is invalid ', done => {
|
||
|
const source = deindent`
|
||
|
<div>{{prop}</div>
|
||
|
`;
|
||
|
|
||
|
const component = svelte.create( source, {
|
||
|
onerror: () => {
|
||
|
done();
|
||
|
}
|
||
|
});
|
||
|
|
||
|
assert.equal( component, undefined );
|
||
|
});
|
||
|
|
||
|
it( 'should return undefined when source is invalid ', () => {
|
||
|
const source = deindent`
|
||
|
<div>{{prop}</div>
|
||
|
`;
|
||
|
|
||
|
const component = svelte.create( source, {
|
||
|
onerror: () => {}
|
||
|
});
|
||
|
|
||
|
assert.equal( component, undefined );
|
||
|
});
|
||
|
});
|