- {names.map(name => (
-
-
- {name}
-
- ))}
+
+
+
+ {names.map(name => (
+
+
+ {name}
+
+ ))}
+
);
};
diff --git a/packages/icons/stories/Icon.tsx b/packages/icons/stories/Icon.tsx
index 6eb20deba74..34aae0b651e 100644
--- a/packages/icons/stories/Icon.tsx
+++ b/packages/icons/stories/Icon.tsx
@@ -373,6 +373,30 @@ const Icon = ({ name, size }: { name: string; size?: keyof typeof iconSizes }) =
);
};
+export const StyleIcon = () => (
+
+);
+
Icon.displayName = 'Icon';
export default Icon;
diff --git a/tools/scripts-config-jest/package.json b/tools/scripts-config-jest/package.json
index 5b533128419..956444e9c4c 100644
--- a/tools/scripts-config-jest/package.json
+++ b/tools/scripts-config-jest/package.json
@@ -17,18 +17,11 @@
"lint": "echo \"Not possible to use talend-scripts here (risk of circular dependency)\" && exit 0",
"test": "jest"
},
- "peerDependencies": {
- "react": ">= 16.14.0",
- "@talend/design-system": "^7.15.1"
- },
"dependencies": {
"@talend/scripts-config-babel": "^13.0.0",
"@testing-library/jest-dom": "^5.17.0",
"@types/jest": "^29.5.5",
- "ally.js": "^1.4.1",
- "jest-axe": "^8.0.0",
"babel-jest": "^29.7.0",
- "classnames": "^2.3.2",
"core-js": "^3.32.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
@@ -37,6 +30,42 @@
"raf": "^3.4.1",
"regenerator-runtime": "^0.13.11"
},
+ "peerDependencies": {
+ "@talend/design-system": ">= 7.15.1",
+ "ally.js": ">= 1.4.1",
+ "i18next": ">= 20.6.1",
+ "classnames": ">= 2.3.2",
+ "jest-axe": ">= 8.0.0",
+ "prop-types": ">= 15.8.1",
+ "react": ">= 16.14.0",
+ "react-i18next": ">= 11.18.6"
+ },
+ "peerDependenciesMeta": {
+ "@talend/design-system": {
+ "optional": true
+ },
+ "ally.js": {
+ "optional": true
+ },
+ "classnames": {
+ "optional": true
+ },
+ "i18next": {
+ "optional": true
+ },
+ "jest-axe": {
+ "optional": true
+ },
+ "prop-types": {
+ "optional": true
+ },
+ "react": {
+ "optional": true
+ },
+ "react-i18next": {
+ "optional": true
+ }
+ },
"publishConfig": {
"access": "public"
}
diff --git a/tools/scripts-config-jest/test-setup.js b/tools/scripts-config-jest/test-setup.js
index be38b8cd6a6..158134583be 100644
--- a/tools/scripts-config-jest/test-setup.js
+++ b/tools/scripts-config-jest/test-setup.js
@@ -12,17 +12,34 @@ require('core-js/stable');
require('regenerator-runtime/runtime');
require('raf/polyfill');
+const warnMessageOptionalDep = (mainDepToMock, depList = []) => {
+ if (depList.length === 0) {
+ console.warn(
+ `JEST MOCK WARN: ${mainDepToMock} is not resolved.` +
+ '\nThis is an optional dependency.' +
+ '\nPlease add it in your dependencies if you need it',
+ );
+ } else if (depList.length > 0) {
+ console.warn(
+ `JEST MOCK WARN: one or more of those deps are not resolved: ${depList.join(', ')}` +
+ 'These are optional dependencies but work together.' +
+ `\nIt's needed to mock ${mainDepToMock}` +
+ '\nPlease add them in your dependencies if you need them',
+ );
+ }
+};
+
try {
const jestAxe = require('jest-axe');
expect.extend(jestAxe.toHaveNoViolations);
} catch (e) {
- console.warn('JEST MOCK WARN: jestAxe not resolved');
+ warnMessageOptionalDep('jest-axe');
}
try {
jest.mock('ally.js');
} catch (e) {
- console.warn('JEST MOCK WARN: ally.js not resolved');
+ warnMessageOptionalDep('ally.js');
}
// add missing ResizeObserver
@@ -49,24 +66,6 @@ if (!global.self.TextEncoder) {
global.self.TextEncoder = require('util').TextEncoder;
global.self.TextDecoder = require('util').TextDecoder;
}
-// enzyme adapter configuration
-let React;
-try {
- React = require('react');
-} catch (e) {}
-
-try {
- const version = React && React.version;
- if (version && version.startsWith('16.')) {
- const configure = require('enzyme').configure;
- const Adapter = require('enzyme-adapter-react-16');
- configure({ adapter: new Adapter() });
- } else if (version && version.startsWith('17.')) {
- const configure = require('enzyme').configure;
- const Adapter = require('@wojtekmaj/enzyme-adapter-react-17');
- configure({ adapter: new Adapter() });
- }
-} catch (e) {}
// Mock fetch
try {
@@ -97,16 +96,6 @@ try {
console.error(e);
}
-try {
- Object.defineProperty(global.self, 'crypto', {
- value: {
- randomUUID: () => '42',
- },
- });
-} catch (e) {
- console.error(e);
-}
-
try {
// Mock session storage
delete window.sessionStorage;
@@ -154,7 +143,11 @@ try {
i18nextMock.addResources = () => {};
return i18nextMock;
});
+} catch (e) {
+ warnMessageOptionalDep('i18next');
+}
+try {
jest.mock('react-i18next', () => {
// from https://github.com/i18next/react-i18next/blob/master/example/test-jest/__mocks__/react-i18next.js
const React = require('react');
@@ -205,7 +198,7 @@ try {
};
});
} catch (e) {
- console.warn('JEST MOCK WARN: i18next not resolved');
+ warnMessageOptionalDep('react-i18next', ['react-i18next', 'i18next', 'react']);
}
try {
@@ -264,17 +257,12 @@ try {
return mocks;
});
} catch {
- console.warn('JEST MOCK WARN: @talend/design-system not resolved');
-}
-
-try {
- // in the case we unmock design-system we don't want id to be random
- jest.mock('reakit/lib/Id/IdProvider', () => ({
- ...jest.requireActual('reakit/lib/Id/IdProvider'),
- unstable_IdContext: jest.requireActual('react').createContext(() => 'id-42'),
- }));
-} catch {
- console.warn('JEST MOCK WARN: reakit/lib/Id/IdProvider not resolved');
+ warnMessageOptionalDep('@talend/design-system', [
+ '@talend/design-system',
+ 'react',
+ 'prop-types',
+ 'classnames',
+ ]);
}
// @floating-ui/react
diff --git a/tools/scripts-config-storybook-lib/.storybook-templates/preview.js b/tools/scripts-config-storybook-lib/.storybook-templates/preview.js
index cd38523daec..d16f55c3ff2 100644
--- a/tools/scripts-config-storybook-lib/.storybook-templates/preview.js
+++ b/tools/scripts-config-storybook-lib/.storybook-templates/preview.js
@@ -96,11 +96,11 @@ const defaultPreview = {
React.createElement(IconsProvider, {
key: 'icons-provider-decorator',
bundles: [
- '/all.svg',
- '/XS.svg',
- '/S.svg',
- '/M.svg',
- '/L.svg',
+ 'all.svg',
+ 'XS.svg',
+ 'S.svg',
+ 'M.svg',
+ 'L.svg',
]
}),
React.createElement(ToggleBootstrap, {