Skip to content

Commit

Permalink
DEV remove enzme, support react 17 testing
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Jun 29, 2023
1 parent dc9bcc3 commit 6008fe7
Show file tree
Hide file tree
Showing 13 changed files with 685 additions and 539 deletions.
6 changes: 3 additions & 3 deletions config/jest.setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ global.renderHook = async (useHook = Function.prototype, { state } = {}) => {
* @returns {*}
*/
global.shallowComponent = async testComponent => {
const renderHook = async (component, updatedProps) => {
const localRenderHook = async (component, updatedProps) => {
if (typeof component?.type === 'function') {
try {
const { result } = await global.renderHook(() =>
Expand All @@ -286,7 +286,7 @@ global.shallowComponent = async testComponent => {
return container.querySelectorAll(sel);
};

const setProps = async p => renderHook(component, p);
const setProps = async p => localRenderHook(component, p);

const renderResult = () => global.renderComponent(result);

Expand Down Expand Up @@ -316,7 +316,7 @@ global.shallowComponent = async testComponent => {
return component;
};

return renderHook(testComponent);
return localRenderHook(testComponent);
};

// FixMe: revisit squashing log and group messaging, redux leaks log messaging
Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = {
resetMocks: true,
roots: ['<rootDir>/src', '<rootDir>/tests'],
setupFilesAfterEnv: ['<rootDir>/config/jest.setupTests.js'],
snapshotSerializers: ['enzyme-to-json/serializer'],
testMatch: ['<rootDir>/**/__tests__/**/*.{js,jsx,ts,tsx}', '<rootDir>/**/*.{spec,test}.{js,jsx,ts,tsx}'],
testEnvironment: 'jsdom',
transform: {
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"@babel/preset-react": "^7.22.5",
"@redhat-cloud-services/frontend-components-config": "5.0.1",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@testing-library/react": "^12.1.5",
"apidoc-mock": "^4.3.0",
"babel-jest": "^29.5.0",
"changelog-light": "^0.4.1",
Expand All @@ -128,8 +128,6 @@
"dotenv": "^16.1.3",
"dotenv-expand": "^10.0.0",
"dotenv-webpack": "^8.0.1",
"enzyme": "^3.11.0",
"enzyme-to-json": "^3.6.2",
"eslint": "8.43.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ exports[`AuthenticationContext should return specific properties: specific prope
"$$typeof": Symbol(react.context),
"Consumer": {
"$$typeof": Symbol(react.context),
"_calculateChangedBits": null,
"_context": [Circular],
},
"Provider": {
"$$typeof": Symbol(react.provider),
"_context": [Circular],
},
"_calculateChangedBits": null,
"_currentRenderer": null,
"_currentRenderer2": null,
"_currentValue": [
Expand All @@ -120,8 +122,6 @@ exports[`AuthenticationContext should return specific properties: specific prope
{},
[Function],
],
"_defaultValue": null,
"_globalName": null,
"_threadCount": 0,
},
"DEFAULT_CONTEXT": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ exports[`ChartContext should return specific properties: specific properties 1`]
"$$typeof": Symbol(react.context),
"Consumer": {
"$$typeof": Symbol(react.context),
"_calculateChangedBits": null,
"_context": [Circular],
},
"Provider": {
"$$typeof": Symbol(react.provider),
"_context": [Circular],
},
"_calculateChangedBits": null,
"_currentRenderer": null,
"_currentRenderer2": null,
"_currentValue": [
Expand All @@ -39,8 +41,6 @@ exports[`ChartContext should return specific properties: specific properties 1`]
},
[Function],
],
"_defaultValue": null,
"_globalName": null,
"_threadCount": 0,
},
"DEFAULT_CONTEXT": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ exports[`Checkbox Component should render a basic component: basic component 1`]
type="checkbox"
value=""
/>
</div>
</checkbox>
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ exports[`GraphCardChart Component should handle API response states: error 1`] =
</CardHeader>
<MinHeight
isOnLoad={false}
key="bodyMinHeight"
minHeight={0}
useResizeObserver={[Function]}
>
Expand Down Expand Up @@ -78,7 +77,6 @@ exports[`GraphCardChart Component should handle API response states: fulfilled 1
</CardHeader>
<MinHeight
isOnLoad={false}
key="bodyMinHeight"
minHeight={0}
useResizeObserver={[Function]}
>
Expand Down Expand Up @@ -135,7 +133,6 @@ exports[`GraphCardChart Component should handle API response states: pending 1`]
</CardHeader>
<MinHeight
isOnLoad={false}
key="bodyMinHeight"
minHeight={0}
useResizeObserver={[Function]}
>
Expand All @@ -158,7 +155,7 @@ exports[`GraphCardChart Component should handle API response states: pending 1`]
</Card>
`;

exports[`GraphCardChart Component should render a default component: default 1`] = `
exports[`GraphCardChart Component should render a basic component: basic 1`] = `
<Card
className="curiosity-usage-graph"
isPlain={true}
Expand All @@ -179,7 +176,6 @@ exports[`GraphCardChart Component should render a default component: default 1`]
</CardHeader>
<MinHeight
isOnLoad={false}
key="bodyMinHeight"
minHeight={0}
useResizeObserver={[Function]}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ exports[`GraphCardContext should return specific properties: specific properties
"$$typeof": Symbol(react.context),
"Consumer": {
"$$typeof": Symbol(react.context),
"_calculateChangedBits": null,
"_context": [Circular],
},
"Provider": {
"$$typeof": Symbol(react.provider),
"_context": [Circular],
},
"_calculateChangedBits": null,
"_currentRenderer": null,
"_currentRenderer2": null,
"_currentValue": [
Expand All @@ -218,8 +220,6 @@ exports[`GraphCardContext should return specific properties: specific properties
},
[Function],
],
"_defaultValue": null,
"_globalName": null,
"_threadCount": 0,
},
"useGetMetrics": [Function],
Expand Down
Loading

0 comments on commit 6008fe7

Please sign in to comment.