Skip to content

Commit 53cd5b9

Browse files
committed
Added tests for reset with data
1 parent 440b8cd commit 53cd5b9

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/routes/reset/+page.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,30 @@
2424
$: form = superF.form;
2525
$: enhance = superF.enhance;
2626
$: errors = superF.errors;
27+
$: reset = superF.reset;
28+
29+
function resetForm() {
30+
console.log('Reset!');
31+
reset({
32+
data: {
33+
points: 4
34+
}
35+
});
36+
}
2737
</script>
2838

2939
<SuperDebug data={$form} />
3040

3141
<div>Resets: {resets}</div>
3242

43+
<div>Points: {$form.points}</div>
44+
3345
<form method="POST" use:enhance>
46+
<input type="hidden" name="points" value="0" /><br />
3447
<input type="text" name="name" bind:value={$form.name} /><br />
3548
{#if $errors.name}<span>{$errors.name}</span><br />{/if}
3649
<button>Submit</button>
50+
<button type="button" on:click={resetForm}>Client reset</button>
3751
</form>
3852

3953
<style lang="scss">

src/routes/reset/schemas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { z } from 'zod';
22

33
export const schema = z.object({
4-
name: z.string().min(2)
4+
name: z.string().min(2),
5+
points: z.number().int()
56
});

0 commit comments

Comments
 (0)