fix: use `compileOption.runes` if defined + add other tests

pull/16232/head
paoloricciuti 3 months ago
parent 5b426bc8e2
commit ed16aa2a81

@ -158,7 +158,10 @@ async function common_setup(cwd: string, runes: boolean | undefined, config: Run
...config.compileOptions,
immutable: config.immutable,
accessors: 'accessors' in config ? config.accessors : true,
runes
runes:
config.compileOptions && 'runes' in config.compileOptions
? config.compileOptions.runes
: runes
};
// load_compiled can be used for debugging a test. It means the compiler will not run on the input

@ -3,6 +3,9 @@ import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');

@ -0,0 +1,17 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.equal(p?.innerHTML, '0');
}
});

@ -0,0 +1,9 @@
<script>
import { get, set } from "./test.svelte.js";
$$props;
</script>
<p>{get()}</p>
<button onclick={()=>set()}></button>

@ -0,0 +1,9 @@
let count = $state(0);
export function get() {
return count;
}
export function set() {
count++;
}

@ -0,0 +1,17 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.equal(p?.innerHTML, '0');
}
});

@ -0,0 +1,9 @@
<script>
import { get, set } from "./test.svelte.js";
$$restProps;
</script>
<p>{get()}</p>
<button onclick={()=>set()}></button>

@ -0,0 +1,9 @@
let count = $state(0);
export function get() {
return count;
}
export function set() {
count++;
}

@ -3,6 +3,9 @@ import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');

@ -0,0 +1,17 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.equal(p?.innerHTML, '0');
}
});

@ -0,0 +1,9 @@
<script>
import { get, set } from "./test.svelte.js";
$: console.log("");
</script>
<p>{get()}</p>
<button onclick={()=>set()}></button>

@ -0,0 +1,9 @@
let count = $state(0);
export function get() {
return count;
}
export function set() {
count++;
}

@ -0,0 +1,17 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.equal(p?.innerHTML, '0');
}
});

@ -0,0 +1,10 @@
<script>
import { get, set } from "./test.svelte.js";
export let x = 42;
</script>
{x}
<p>{get()}</p>
<button onclick={()=>set()}></button>

@ -0,0 +1,9 @@
let count = $state(0);
export function get() {
return count;
}
export function set() {
count++;
}

@ -3,12 +3,15 @@ import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');
flushSync(() => {
btn?.click();
});
assert.equal(p?.innerHTML, '1');
assert.equal(p?.innerHTML, '0');
}
});

@ -3,6 +3,9 @@ import { test } from '../../test';
export default test({
mode: ['client'],
compileOptions: {
runes: undefined
},
async test({ assert, target }) {
const p = target.querySelector('p');
const btn = target.querySelector('button');

Loading…
Cancel
Save