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",
"pnpm-workspace.yaml",
"pnpm-lock.yaml",
"napi/transform/index.js",
"napi/{transform,minify}/index.js",
"napi/parser/bindings.js",
"napi/{parser,transform}/index.d.ts",
"napi/{parser,transform,minify}/index.d.ts",
"npm/*/package.json",
"npm/oxlint/configuration_schema.json",
".github/.generated_ast_watch_list.yml"

View file

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