fix(napi/transform): fix test

This commit is contained in:
Boshen 2024-10-28 09:06:46 +08:00
parent 5d6997502b
commit dcdb9ead4e
No known key found for this signature in database
GPG key ID: 67715A371E534061
2 changed files with 19 additions and 17 deletions

View file

@ -17,9 +17,9 @@
"**/CHANGELOG.md", "**/CHANGELOG.md",
"pnpm-workspace.yaml", "pnpm-workspace.yaml",
"pnpm-lock.yaml", "pnpm-lock.yaml",
"napi/transform/index.js", "napi/{transform,minify}/index.js",
"napi/parser/bindings.js", "napi/parser/bindings.js",
"napi/{parser,transform}/index.d.ts", "napi/{parser,transform,minify}/index.d.ts",
"npm/*/package.json", "npm/*/package.json",
"npm/oxlint/configuration_schema.json", "npm/oxlint/configuration_schema.json",
".github/.generated_ast_watch_list.yml" ".github/.generated_ast_watch_list.yml"

View file

@ -35,23 +35,25 @@ describe('react refresh plugin', () => {
it('matches output', () => { it('matches output', () => {
const ret = oxc.transform('test.tsx', code, { jsx: { refresh: {} } }); const ret = oxc.transform('test.tsx', code, { jsx: { refresh: {} } });
console.log(ret.code)
assert.equal( assert.equal(
ret.code, ret.code,
'var _s = $RefreshSig$();\n' + `import { useState } from "react";
'import { useState } from "react";\n' + import { jsxs as _jsxs } from "react/jsx-runtime";
'import { jsxs as _jsxs } from "react/jsx-runtime";\n' + var _s = $RefreshSig$();
'export const App = () => {\n' + export const App = () => {
'\t_s();\n' + _s();
'\tconst [count, setCount] = useState(0);\n' + const [count, setCount] = useState(0);
'\treturn _jsxs("button", {\n' + return _jsxs("button", {
'\t\tonClick: () => setCount(count + 1),\n' + onClick: () => setCount(count + 1),
'\t\tchildren: ["count is ", count]\n' + children: ["count is ", count]
'\t});\n' + });
'};\n' + };
'_s(App, "oDgYfYHkD9Wkv4hrAPCkI/ev3YU=");\n' + _s(App, "oDgYfYHkD9Wkv4hrAPCkI/ev3YU=");
'_c = App;\n' + _c = App;
'var _c;\n' + var _c;
'$RefreshReg$(_c, "App");\n', $RefreshReg$(_c, "App");
`
); );
}); });
}); });