diff --git a/src/lib/generators/code-snippet-generators.spec.ts b/src/lib/generators/code-snippet-generators.spec.ts index bc68781..de9c18b 100644 --- a/src/lib/generators/code-snippet-generators.spec.ts +++ b/src/lib/generators/code-snippet-generators.spec.ts @@ -11,6 +11,7 @@ import { generateNamedImportStatement, generateObjectInterface, generateSvgConstant, + generateTSXConstant, generateTypeDefinition, generateTypeHelper, generateTypeHelperWithImport, @@ -260,4 +261,13 @@ describe('Generators', () => { expect(unformatedString(generatedStatement)).toEqual(unformatedString(expectedStatement)); }); }); + + describe('TSX', () => { + it('should convert a svg to a React component', () => { + const expected = `export const Smile = (props: {[key: string]: any}) => ();`; + + const actual = generateTSXConstant('smile', ''); + expect(actual).toEqual(expected); + }); + }); }); diff --git a/src/lib/generators/code-snippet-generators.ts b/src/lib/generators/code-snippet-generators.ts index fcd9560..9e060ac 100644 --- a/src/lib/generators/code-snippet-generators.ts +++ b/src/lib/generators/code-snippet-generators.ts @@ -113,7 +113,7 @@ export const generateSvgConstant = (variableName: string, filenameWithoutEnding: export function generateTSXConstant(variableName: string, svg: string) { const variableNameCapitalized = variableName.charAt(0).toUpperCase() + variableName.slice(1); const svgStringWithProps = svg.replace('>', ' {...props}>'); - return `export const ${variableNameCapitalized} = (props) => (${svgStringWithProps});`; + return `export const ${variableNameCapitalized} = (props: {[key: string]: any}) => (${svgStringWithProps});`; } export const generateExportStatement = (fileName: string, generatedIconsFolderName?: string): string => {