Skip to content

Commit

Permalink
Chore: add test for preact aliasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed Dec 11, 2021
1 parent 6081742 commit ca600b4
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 1 deletion.
@@ -0,0 +1 @@
module.exports = <div />;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,12 @@
{
"private": true,
"dependencies": {
"preact": "^10.5"
},
"alias": {
"react": "preact/compat",
"react-dom/test-utils": "preact/test-utils",
"react-dom": "preact/compat",
"react/jsx-runtime": "preact/jsx-runtime"
}
}
Empty file.
15 changes: 14 additions & 1 deletion packages/core/integration-tests/test/transpilation.js
Expand Up @@ -120,7 +120,7 @@ describe('transpilation', function () {
await bundle(path.join(__dirname, '/integration/jsx-react-alias/index.js'));

let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8');
assert(file.includes('React.createElement("div"'));
assert(file.includes('h("div"'));
});

it('should support compiling JSX in JS files with Preact dependency', async function () {
Expand Down Expand Up @@ -183,6 +183,19 @@ describe('transpilation', function () {
assert(file.includes('_jsxRuntime.jsx("div"'));
});

it('should support the automatic JSX runtime with preact with alias', async function () {
let b = await bundle(
path.join(
__dirname,
'/integration/jsx-automatic-preact-with-alias/index.js',
),
);

let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf8');
assert(file.includes('preact/jsx-runtime'));
assert(file.includes('_jsxRuntime.jsx("div"'));
});

it('should support the automatic JSX runtime with explicit tsconfig.json', async function () {
let b = await bundle(
path.join(__dirname, '/integration/jsx-automatic-tsconfig/index.js'),
Expand Down

0 comments on commit ca600b4

Please sign in to comment.