Skip to content

Commit 06d9110

Browse files
author
Viktor Pasynok
committed
changed: type test
1 parent 4a84371 commit 06d9110

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

src/__tests__/payload.spec-d.tsx

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,47 @@
11
import React from 'react';
22
import { expectTypeOf } from 'vitest';
3-
import { type Payload } from '../init';
3+
import { createSlotIdentifier, createSlots, type EmptyObject } from '../init';
44

5-
type EmptyObject = Record<string, never>;
5+
const slotId = createSlotIdentifier<{ text: string }>();
6+
const noPropsSlot = createSlotIdentifier<void>();
67

7-
declare const payload: Payload<{ name: string }>;
8+
const { slotsApi } = createSlots({
9+
Top: slotId,
10+
Bottom: noPropsSlot,
11+
});
812

9-
payload({
10-
fn: (data) => ({ label: data.name }),
13+
slotsApi.insert.into.Top({
14+
fn: (data) => ({ text: data.text }),
1115
component: (props) => {
12-
expectTypeOf<{ label: string }>(props);
16+
expectTypeOf<{ text: string }>(props);
1317
return <div />;
1418
},
1519
});
1620

17-
payload({
21+
slotsApi.insert.into.Top({
1822
component: (props) => {
1923
expectTypeOf<EmptyObject>(props);
2024
return <div />;
2125
},
2226
});
2327

24-
payload({
28+
slotsApi.insert.into.Top({
2529
fn: () => {},
2630
component: (props) => {
2731
expectTypeOf<EmptyObject>(props);
2832
return <div />;
2933
},
3034
});
3135

32-
payload({
33-
fn: (data) => ({ label: data.name }),
34-
// @ts-expect-error expected { label: string } but got { wrong: number }
36+
slotsApi.insert.into.Bottom({
37+
component: (props) => {
38+
expectTypeOf<EmptyObject>(props);
39+
return <div />;
40+
},
41+
});
42+
43+
slotsApi.insert.into.Top({
44+
fn: (data) => ({ text: data.text }),
45+
// @ts-expect-error
3546
component: (_: { wrong: number }) => <div />,
3647
});

0 commit comments

Comments
 (0)