mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix unit tests
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
c5379ad9f9
commit
10124abd18
@ -3,4 +3,4 @@
|
||||
* 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)
|
||||
@ -62,7 +62,7 @@
|
||||
},
|
||||
"moduleNameMapper": {
|
||||
"\\.(css|scss)$": "<rootDir>/__mocks__/styleMock.ts",
|
||||
"\\.(svg)$": "<rootDir>/__mocks__/imageMock.ts"
|
||||
"\\.(svg|png|jpg|eot|woff2?|ttf)$": "<rootDir>/__mocks__/assetMock.ts"
|
||||
},
|
||||
"modulePathIgnorePatterns": [
|
||||
"<rootDir>/dist",
|
||||
|
||||
@ -37,7 +37,7 @@ export class Icon extends React.PureComponent<IconProps> {
|
||||
focusable: true,
|
||||
};
|
||||
|
||||
static isSvg(content: string){
|
||||
static isSvg(content: string) {
|
||||
return String(content).includes("svg+xml"); // data-url for raw svg-icon
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ export class Icon extends React.PureComponent<IconProps> {
|
||||
switch (evt.nativeEvent.code) {
|
||||
case "Space":
|
||||
|
||||
// fallthrough
|
||||
// fallthrough
|
||||
case "Enter": {
|
||||
this.ref.current?.click();
|
||||
evt.preventDefault();
|
||||
@ -104,10 +104,11 @@ export class Icon extends React.PureComponent<IconProps> {
|
||||
// render as inline svg-icon
|
||||
if (typeof svg === "string") {
|
||||
const dataUrlPrefix = "data:image/svg+xml;base64,";
|
||||
const svgIconDataUrl: string = svg.startsWith(dataUrlPrefix) ? svg : require(`./${svg}.svg`);
|
||||
const svgIconText = decode(svgIconDataUrl.replace(dataUrlPrefix, "")); // get raw xml
|
||||
const svgIconDataUrl = svg.startsWith(dataUrlPrefix) ? svg : require(`./${svg}.svg`);
|
||||
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 }} />;
|
||||
}
|
||||
|
||||
// render as material-icon
|
||||
@ -135,7 +136,7 @@ export class Icon extends React.PureComponent<IconProps> {
|
||||
}
|
||||
|
||||
if (href) {
|
||||
return <a {...iconProps} href={href} ref={this.ref}/>;
|
||||
return <a {...iconProps} href={href} ref={this.ref} />;
|
||||
}
|
||||
|
||||
return <i {...iconProps} ref={this.ref} />;
|
||||
|
||||
1
types/mocks.d.ts
vendored
1
types/mocks.d.ts
vendored
@ -27,6 +27,7 @@ declare module "*.scss" {
|
||||
}
|
||||
|
||||
// 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 "*.jpg";
|
||||
declare module "*.png";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user