forked from parcel-bundler/parcel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
svg-react-typescript.js
32 lines (29 loc) 路 1011 Bytes
/
svg-react-typescript.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import assert from 'assert';
import {bundle, outputFS} from '@parcel/test-utils';
import path from 'path';
describe('svg-react-typescript', () => {
let file, types, b;
before(async () => {
b = await bundle(
path.join(__dirname, '/integration/svg-react-typescript/react.ts'),
{
defaultConfig: path.join(
__dirname,
'integration/custom-configs/.parcelrc-svg-react',
),
defaultTargetOptions: {
typescript: true,
},
},
);
file = await outputFS.readFile(b.getBundles()[0].filePath, 'utf-8');
types = await outputFS.readFile(b.getBundles()[1].filePath, 'utf-8');
});
it('should support transforming SVGs to typescript react components', function () {
assert(!file.includes('inkscape'));
assert(file.includes('react.createElement("svg"'));
});
it('should support generating typescript types for SVG react components', function () {
assert(types.includes('const Icon: SVGRComponent'));
});
});