fix unit tests

Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
Roman committed 2022-02-09 13:15:25 +02:00
1 parent c5379ad9f9
commit 10124abd18
4 files changed
+6 -4

No files matched your search

@@ -3,4 +3,4 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
export default {}; export default ""; // mostly path to bundled file or data-url (webpack)
+1 -1
View File
@@ -62,7 +62,7 @@
}, },
"moduleNameMapper": { "moduleNameMapper": {
"\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.ts", "\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.ts",
"\\.(svg)$": "<rootDir>/__mocks__/imageMock.ts" "\\.(svg|png|jpg|eot|woff2?|ttf)$": "<rootDir>/__mocks__/assetMock.ts"
}, },
"modulePathIgnorePatterns": [ "modulePathIgnorePatterns": [
"<rootDir>/dist", "<rootDir>/dist",
+3 -2
View File
@@ -104,8 +104,9 @@ export class Icon extends React.PureComponent<IconProps> {
// render as inline svg-icon // render as inline svg-icon
if (typeof svg === "string") { if (typeof svg === "string") {
const dataUrlPrefix = "data:image/svg+xml;base64,"; const dataUrlPrefix = "data:image/svg+xml;base64,";
const svgIconDataUrl: string = svg.startsWith(dataUrlPrefix) ? svg : require(`./${svg}.svg`); const svgIconDataUrl = svg.startsWith(dataUrlPrefix) ? svg : require(`./${svg}.svg`);
const svgIconText = decode(svgIconDataUrl.replace(dataUrlPrefix, "")); // get raw xml const svgIconText = typeof svgIconDataUrl == "string" // decode xml from data-url
? decode(svgIconDataUrl.replace(dataUrlPrefix, "")) : "";
iconContent = <span className="icon" dangerouslySetInnerHTML={{ __html: svgIconText }} />; iconContent = <span className="icon" dangerouslySetInnerHTML={{ __html: svgIconText }} />;
} }
+1
View File
@@ -27,6 +27,7 @@ declare module "*.scss" {
} }
// Declare everything what's bundled as webpack's type="asset/resource" // Declare everything what's bundled as webpack's type="asset/resource"
// Should be mocked for tests support in jestConfig.moduleNameMapper (currently in "/package.json")
declare module "*.svg"; declare module "*.svg";
declare module "*.jpg"; declare module "*.jpg";
declare module "*.png"; declare module "*.png";