Skip to content

Commit f3804ca

Browse files
committed
test
1 parent db46ad7 commit f3804ca

File tree

6 files changed

+50
-25
lines changed

6 files changed

+50
-25
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { flushSync } from 'svelte';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
compileOptions: {
6+
dev: true
7+
},
8+
9+
html: '<p>42</p><p>42</p><button>update</button><button>reset</button>',
10+
11+
test({ assert, target }) {
12+
const [update, reset] = target.querySelectorAll('button');
13+
flushSync(() => update.click());
14+
15+
assert.htmlEqual(
16+
target.innerHTML,
17+
'<p>42</p><p>42</p><button>update</button><button>reset</button>'
18+
);
19+
20+
flushSync(() => reset.click());
21+
},
22+
23+
warnings: [
24+
'A `$:` statement (main.svelte:4:1) read reactive state that was not visible to the compiler. Updates to this state will not cause the statement to re-run. The behaviour of this code will change if you migrate it to runes mode'
25+
]
26+
});
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export const obj = $state({
2+
prop: 42
3+
});
4+
5+
export function update() {
6+
obj.prop += 1;
7+
}
8+
9+
export function reset() {
10+
obj.prop = 42;
11+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script>
2+
import { obj, update, reset } from './data.svelte.js';
3+
4+
$: a = obj.prop;
5+
6+
// svelte-ignore reactive_declaration_non_reactive_property
7+
$: b = obj.prop;
8+
</script>
9+
10+
<p>{a}</p>
11+
<p>{b}</p>
12+
<button on:click={update}>update</button>
13+
<button on:click={reset}>reset</button>

packages/svelte/tests/validator/samples/reactive-statement-non-reactive-import-statement/_config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/svelte/tests/validator/samples/reactive-statement-non-reactive-import-statement/input.svelte

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/svelte/tests/validator/samples/reactive-statement-non-reactive-import-statement/warnings.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)