Skip to content

Commit

Permalink
Add tests for render props (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandrHoroshih authored Feb 8, 2024
1 parent 5da0fc7 commit 60f5c02
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/no-ssr/reflect.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,42 @@ describe('plain callbacks with scopeBind under the hood', () => {
expect(scope.getState($name)).toBe('Bob');
expect($name.getState()).toBe('');
});

test('render props work', async () => {
const RenderComp = (props: {
prefix: string;
renderMe: (props: { value: string }) => React.ReactNode;
}) => {
return <div>{props.renderMe({ value: `${props.prefix}: text` })}</div>;
};
const Text = (props: { value: string }) => {
return <span>{props.value}</span>;
};

const ReflectedRender = reflect({
view: RenderComp,
bind: {
prefix: createStore('Hello'),
renderMe: Text,
},
});

const scope = fork();

const container = render(
<Provider value={scope}>
<ReflectedRender />
</Provider>,
);

expect(container.container.firstChild).toMatchInlineSnapshot(`
<div>
<span>
Hello: text
</span>
</div>
`);
});
});

describe('hooks', () => {
Expand Down

0 comments on commit 60f5c02

Please sign in to comment.