update some tests

pull/1864/head
Rich Harris 7 years ago
parent f60487df2f
commit d9854c5dd6

@ -3,37 +3,13 @@ import { svelte, deindent } from "../helpers.js";
describe("create", () => {
it("should return a component constructor", () => {
const source = deindent`
<div>{prop}</div>
`;
const component = svelte.create(source);
const component = svelte.create(`<div>{prop}</div>`);
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);
assert.throws(() => {
svelte.create(`<div>{prop</div>`);
}, /TODO/);
});
});

@ -48,27 +48,6 @@ describe('parse', () => {
});
});
// TODO remove in v3
it('handles errors with options.onerror', () => {
let errored = false;
svelte.compile(`<h1>unclosed`, {
onerror(err) {
errored = true;
assert.equal(err.message, `<h1> was left open`);
}
});
assert.ok(errored);
});
// TODO remove in v3
it('throws without options.onerror', () => {
assert.throws(() => {
svelte.compile(`<h1>unclosed`);
}, /<h1> was left open/);
});
it('includes AST in svelte.compile output', () => {
const source = fs.readFileSync(`test/parser/samples/attribute-dynamic/input.html`, 'utf-8');

@ -55,6 +55,8 @@ describe.only("runtime", () => {
const config = loadConfig(`./runtime/samples/${dir}/_config.js`);
if (hydrate && config.skip_if_hydrate) return;
if (config.solo && process.env.CI) {
throw new Error("Forgot to remove `solo: true` from test");
}
@ -74,8 +76,6 @@ describe.only("runtime", () => {
compileOptions.shared = internal;
compileOptions.hydratable = hydrate;
compileOptions.immutable = config.immutable;
compileOptions.skipIntroByDefault = config.skipIntroByDefault;
compileOptions.nestedTransitions = config.nestedTransitions;
Object.keys(require.cache)
.filter(x => x.endsWith(".html"))
@ -117,7 +117,7 @@ describe.only("runtime", () => {
try {
SvelteComponent = require(`./samples/${dir}/main.html`);
} catch (err) {
showOutput(cwd, { internal, format: 'cjs', hydratable: hydrate, skipIntroByDefault: compileOptions.skipIntroByDefault, nestedTransitions: compileOptions.nestedTransitions }, svelte.compile); // eslint-disable-line no-console
showOutput(cwd, { internal, format: 'cjs', hydratable: hydrate }, svelte.compile); // eslint-disable-line no-console
throw err;
}
@ -183,8 +183,6 @@ describe.only("runtime", () => {
internal,
format: 'cjs',
hydratable: hydrate,
skipIntroByDefault: compileOptions.skipIntroByDefault,
nestedTransitions: compileOptions.nestedTransitions,
dev: compileOptions.dev
}, svelte.compile); // eslint-disable-line no-console
throw err;
@ -195,9 +193,7 @@ describe.only("runtime", () => {
showOutput(cwd, {
internal,
format: 'cjs',
hydratable: hydrate,
skipIntroByDefault: compileOptions.skipIntroByDefault,
nestedTransitions: compileOptions.nestedTransitions
hydratable: hydrate
}, svelte.compile);
}

@ -3,8 +3,6 @@ export default {
x: true
},
nestedTransitions: true,
test(assert, component) {
component.x = false;
}

@ -3,8 +3,6 @@ export default {
<p>Foo</p>
`,
nestedTransitions: true,
test(assert, component, target) {
const Bar = component.Bar;

@ -1,5 +1,4 @@
export default {
nestedTransitions: true,
props: { items: [] },
html: `No items.`,
};

@ -10,8 +10,6 @@ export default {
</div>
`,
nestedTransitions: true,
test(assert, component, target) {
component.visible = false;

@ -1,7 +1,4 @@
export default {
skipIntroByDefault: true,
nestedTransitions: true,
props: {
foo: true,
},

@ -8,8 +8,6 @@ export default {
<span>1</span>
`,
nestedTransitions: true,
test(assert, component, target) {
component.x = 2;
assert.htmlEqual(target.innerHTML, `

@ -1,6 +1,4 @@
export default {
nestedTransitions: true,
html: `
<div>A wild component appears</div>
<p>x</p>

@ -1,7 +1,5 @@
export default {
nestedTransitions: true,
test ( assert, component, target ) {
test(assert, component, target) {
// Would cause "TypeError: Cannot read property 'o' of undefined"
component.foo = false;
}

@ -1,5 +1,4 @@
export default {
nestedTransitions: true,
html: `
<div></div>
<div></div>

@ -8,9 +8,7 @@ export default {
html: ``,
compileOptions: {
dev: true,
nestedTransitions: true,
skipIntroByDefault: true,
dev: true
},
test(assert, component, target, window, raf) {

@ -13,8 +13,6 @@ export default {
</li>
`,
nestedTransitions: true,
test(assert, component, target, window, raf) {
component.folder.open = false;
assert.htmlEqual(target.innerHTML, `

@ -11,8 +11,6 @@ export default {
</div>
`,
nestedTransitions: true,
test(assert, component, target, window, raf) {
const div = target.querySelector('div');
const { appendChild, insertBefore } = div;

@ -1,7 +1,7 @@
export default {
intro: true,
test(assert, component, target, window, raf) {
component.visible = true;
const div = target.querySelector('div');
assert.equal(div.foo, 42);

@ -1,5 +1,6 @@
<script>
export let x = 42;
export let visible = false;
function foo(node, params) {
return {
@ -11,4 +12,6 @@
}
</script>
<div transition:foo></div>
{#if visible}
<div transition:foo></div>
{/if}

@ -1,6 +1,4 @@
export default {
skipIntroByDefault: true,
props: {
visible: true
},

@ -1,7 +1,4 @@
export default {
nestedTransitions: true,
skipIntroByDefault: true,
props: {
x: true,
},

@ -1,7 +1,7 @@
export default {
intro: true,
test(assert, component, target, window, raf) {
component.visible = true;
const div = target.querySelector('div');
assert.equal(div.foo, 0);

@ -1,4 +1,6 @@
<script>
export let visible = false;
function foo(node, params) {
return {
duration: 100,
@ -9,4 +11,6 @@
}
</script>
<div transition:foo></div>
{#if visible}
<div transition:foo></div>
{/if}

@ -1,7 +1,8 @@
export default {
skipIntroByDefault: true,
intro: true,
skip_if_hydrate: true,
test(assert, component, target, window, raf) {
const div = target.querySelector('div');
assert.equal(div.foo, 0);

@ -1,6 +1,4 @@
export default {
skipIntroByDefault: true,
test(assert, component, target, window, raf) {
const div = target.querySelector('div');
assert.equal(div.foo, undefined);

@ -1,6 +1,4 @@
export default {
skipIntroByDefault: true,
test(assert, component, target, window, raf) {
const div = target.querySelector('div');
assert.equal(div.foo, undefined);

@ -5,9 +5,6 @@ const promise = new Promise(f => {
});
export default {
skipIntroByDefault: true,
nestedTransitions: true,
props: {
x: false,
promise

@ -1,7 +1,4 @@
export default {
skipIntroByDefault: true,
nestedTransitions: true,
props: {
x: false
},

@ -1,7 +1,4 @@
export default {
nestedTransitions: true,
skipIntroByDefault: true,
props: {
visible: true,
things: [ 'a', 'b', 'c' ]

@ -1,6 +1,4 @@
export default {
nestedTransitions: true,
props: {
x: true,
things: ['a', 'b']

@ -1,7 +1,4 @@
export default {
skipIntroByDefault: true,
nestedTransitions: true,
props: {
x: false,
things: ['a']

@ -1,7 +1,4 @@
export default {
skipIntroByDefault: true,
nestedTransitions: true,
props: {
x: false,
things: ['a']

@ -1,7 +1,4 @@
export default {
skipIntroByDefault: true,
nestedTransitions: true,
props: {
x: false,
y: true

Loading…
Cancel
Save