Skip to content

Commit ddf1bb0

Browse files
committed
refactor: use describe and it for organization
1 parent b619171 commit ddf1bb0

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { expectTypeOf } from 'expect-type';
22
import { isInputError, defineAction } from '../../dist/actions/runtime/virtual/server.js';
33
import { z } from '../../zod.mjs';
4+
import { describe, it } from 'node:test';
45

56
const exampleAction = defineAction({
67
input: z.object({
@@ -11,16 +12,20 @@ const exampleAction = defineAction({
1112

1213
const result = await exampleAction.safe({ name: 'Alice' });
1314

14-
// `isInputError` narrows unknown error types
15-
try {
16-
await exampleAction({ name: 'Alice' });
17-
} catch (e) {
18-
if (isInputError(e)) {
19-
expectTypeOf(e.fields).toEqualTypeOf<Record<string, string[] | undefined>>();
20-
}
21-
}
15+
describe('isInputError', () => {
16+
it('isInputError narrows unknown error types', async () => {
17+
try {
18+
await exampleAction({ name: 'Alice' });
19+
} catch (e) {
20+
if (isInputError(e)) {
21+
expectTypeOf(e.fields).toEqualTypeOf<Record<string, string[] | undefined>>();
22+
}
23+
}
24+
});
2225

23-
// `isInputError` preserves `fields` object type for ActionError objects
24-
if (isInputError(result.error)) {
25-
expectTypeOf(result.error.fields).toEqualTypeOf<{ name?: string[] }>();
26-
}
26+
it('`isInputError` preserves `fields` object type for ActionError objects', async () => {
27+
if (isInputError(result.error)) {
28+
expectTypeOf(result.error.fields).toEqualTypeOf<{ name?: string[] }>();
29+
}
30+
});
31+
});

0 commit comments

Comments
 (0)