Skip to content

Commit

Permalink
Add test for svg-react .svgrrc
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Feb 28, 2022
1 parent e10c41b commit f2086a3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
@@ -0,0 +1,4 @@
{
"icon": true,
"jsxRuntime": "classic-preact"
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1 @@
<img src="icon.svg" />
@@ -0,0 +1,5 @@
{
"dependencies": {
"preact": "*"
}
}
@@ -0,0 +1,4 @@
const { h } = require('preact');
const PreactIcon = require('./icon.svg');

module.exports = <PreactIcon />;
18 changes: 18 additions & 0 deletions packages/core/integration-tests/test/svg-react.js
Expand Up @@ -19,4 +19,22 @@ describe('svg-react', function () {
assert(file.includes('const SvgIcon ='));
assert(file.includes('_react.createElement("svg"'));
});

it('should find and use a .svgrrc config file', async function () {
let b = await bundle(
path.join(__dirname, '/integration/svg-react-svgrrc/react.js'),
{
defaultConfig: path.join(
__dirname,
'integration/custom-configs/.parcelrc-svg-react',
),
},
);

let file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf-8');
assert(!file.includes('inkscape'));
assert(file.includes('const SvgIcon ='));
assert(file.includes('h("svg"'));
assert(file.includes('width: "1em"'));
});
});

0 comments on commit f2086a3

Please sign in to comment.