Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
XantreDev committed Aug 30, 2024
1 parent 22be07e commit 20a6dce
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/react/test/babel/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -802,4 +802,40 @@ describe("React Signals Babel Transform", () => {
expect(signalsBinding.referenced).toBeTruthy();
});
});

it("must transform components wrapped with HOCs", async () => {
const inputCode = `
import {forwardRef} from "react";
const Component = forwardRef(() => <div></div>);
`;

const expectedOutput = `
import {forwardRef} from 'react'
import { useSignals as _useSignals } from "custom-source";
const Component = forwardRef(() => {
var _effect = _useSignals();
try {
return <div></div>;
} finally {
_effect.f();
}
});
`;

await runTest(
expect,
inputCode,
expectedOutput,
{
type: "babel",
options: {
importSource: "custom-source",
mode: "all",
},
},
false,
false
);
});
});

0 comments on commit 20a6dce

Please sign in to comment.