Skip to content

Commit beeb449

Browse files
committed
Test updates
1 parent e3b2d37 commit beeb449

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/routes/(v2)/v2/issue-485/+page.svelte

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import { schema } from './schema.js';
77
import { debounce } from 'throttle-debounce';
88
9+
let isSuccess = true;
10+
let shouldThrowIfNotSuccess = true;
11+
let defaultStatus = false;
12+
913
const { form, errors, message, enhance, submit, submitting } = superForm(
1014
defaults({ email: '[email protected]', name: 'aaa' }, zod(schema)),
1115
{
@@ -20,7 +24,7 @@
2024
errors: Record<string, string[]>;
2125
} & Record<string, unknown>;
2226
23-
result.status = error.status;
27+
if (!defaultStatus) result.status = error.status;
2428
form.errors = error.errors;
2529
},
2630
async onUpdate({ form, result }) {
@@ -31,7 +35,6 @@
3135
return;
3236
}
3337
34-
const isSuccess = false; //Math.random() >= 0.5;
3538
console.log('isSuccess', isSuccess);
3639
3740
if (isSuccess) {
@@ -54,16 +57,15 @@
5457
}
5558
};
5659
57-
const shouldThrow = false; //Math.random() >= 0.5;
58-
console.log('shouldThrow', shouldThrow);
60+
console.log('shouldThrow', shouldThrowIfNotSuccess);
5961
60-
if (shouldThrow) {
62+
if (shouldThrowIfNotSuccess) {
6163
// 3. This will update the status in the next release:
6264
throw madeupProblemDetails;
6365
}
6466
6567
setError(form, 'name', ['random error']);
66-
result.status = 422;
68+
if (!defaultStatus) result.status = 423;
6769
result.type = 'failure';
6870
// 3. Cannot set data to anything else than a SuperValidated object. In general, tamper as little as possible with the result
6971
// 4. Focus will be kept when this is commented out.
@@ -83,6 +85,14 @@
8385

8486
<h3>onError testing</h3>
8587

88+
<div>
89+
<input type="checkbox" bind:checked={isSuccess} /> Succeed
90+
<br />
91+
<input type="checkbox" bind:checked={shouldThrowIfNotSuccess} /> Throw if not success
92+
<br />
93+
<input type="checkbox" bind:checked={defaultStatus} /> Status 500 on error
94+
</div>
95+
8696
{#if $message}
8797
<pre
8898
class="status"

0 commit comments

Comments
 (0)