Skip to content

Commit ae0753a

Browse files
authored
[]: Migrate widgets to use enzyme-free command for unit tests (#1627)
2 parents e150f96 + b184c62 commit ae0753a

File tree

27 files changed

+719
-1464
lines changed

27 files changed

+719
-1464
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
]
4040
},
4141
"overrides": {
42-
"@mendix/pluggable-widgets-tools": "10.21.0",
42+
"@mendix/pluggable-widgets-tools": "10.21.1",
4343
"react": "^18.0.0",
4444
"react-dom": "^18.0.0",
4545
"prettier": "3.5.3",

packages/pluggableWidgets/accordion-web/jest.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/pluggableWidgets/accordion-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"publish-marketplace": "rui-publish-marketplace",
3939
"release": "pluggable-widgets-tools release:web",
4040
"start": "pluggable-widgets-tools start:server",
41-
"test": "jest --projects jest.config.js",
41+
"test": "pluggable-widgets-tools test:unit:web:enzyme-free",
4242
"update-changelog": "rui-update-changelog-widget",
4343
"verify": "rui-verify-package-format"
4444
},

packages/pluggableWidgets/badge-button-web/jest.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/pluggableWidgets/badge-button-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"publish-marketplace": "rui-publish-marketplace",
3838
"release": "cross-env MPKOUTPUT=BadgeButton.mpk pluggable-widgets-tools release:web",
3939
"start": "cross-env MPKOUTPUT=BadgeButton.mpk pluggable-widgets-tools start:server",
40-
"test": "jest --projects jest.config.js",
40+
"test": "pluggable-widgets-tools test:unit:web:enzyme-free",
4141
"update-changelog": "rui-update-changelog-widget",
4242
"verify": "rui-verify-package-format"
4343
},

packages/pluggableWidgets/badge-web/jest.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/pluggableWidgets/badge-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"publish-marketplace": "rui-publish-marketplace",
3838
"release": "cross-env MPKOUTPUT=Badge.mpk pluggable-widgets-tools release:web",
3939
"start": "cross-env MPKOUTPUT=Badge.mpk pluggable-widgets-tools start:server",
40-
"test": "jest --projects jest.config.js",
40+
"test": "pluggable-widgets-tools test:unit:web:enzyme-free",
4141
"update-changelog": "rui-update-changelog-widget",
4242
"verify": "rui-verify-package-format"
4343
},

packages/pluggableWidgets/color-picker-web/jest.config.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/pluggableWidgets/color-picker-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"publish-marketplace": "rui-publish-marketplace",
3939
"release": "cross-env MPKOUTPUT=ColorPicker.mpk pluggable-widgets-tools release:web",
4040
"start": "cross-env MPKOUTPUT=ColorPicker.mpk pluggable-widgets-tools start:server",
41-
"test": "jest --projects jest.config.js",
41+
"test": "pluggable-widgets-tools test:unit:web:enzyme-free",
4242
"update-changelog": "rui-update-changelog-widget",
4343
"verify": "rui-verify-package-format"
4444
},

packages/pluggableWidgets/column-chart-web/src/__tests__/ColumnChart.spec.tsx

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { ChartWidget } from "@mendix/shared-charts/main";
2-
import { EditableValueBuilder, ListAttributeValueBuilder, list, listExp } from "@mendix/widget-plugin-test-utils";
3-
import Big from "big.js";
1+
import { ChartWidget, setupBasicSeries } from "@mendix/shared-charts/main";
2+
import { listExpression } from "@mendix/widget-plugin-test-utils";
43
import { render, RenderResult } from "@testing-library/react";
54
import { createElement } from "react";
65
import { ColumnChartContainerProps, SeriesType } from "../../typings/ColumnChartProps";
@@ -26,7 +25,7 @@ describe("The ColumnChart widget", () => {
2625
name="column-chart-test"
2726
class="column-chart-class"
2827
barmode="group"
29-
series={configs.map(setupBasicSeries)}
28+
series={configs.map(setupBasicColumnSeries)}
3029
showLegend={false}
3130
widthUnit="percentage"
3231
width={0}
@@ -58,7 +57,7 @@ describe("The ColumnChart widget", () => {
5857
});
5958

6059
it("sets the bar color on the data series based on the barColor value", () => {
61-
renderColumnChart([{ staticBarColor: listExp(() => "red") }, { staticBarColor: undefined }]);
60+
renderColumnChart([{ staticBarColor: listExpression(() => "red") }, { staticBarColor: undefined }]);
6261

6362
const mockCalls = (ChartWidget as jest.Mock).mock.calls;
6463
const lastCallProps = mockCalls[mockCalls.length - 1][0];
@@ -105,26 +104,11 @@ describe("The ColumnChart widget", () => {
105104
});
106105
});
107106

108-
function setupBasicSeries(overwriteConfig: Partial<SeriesType>): SeriesType {
109-
const xAttribute = new ListAttributeValueBuilder<Big>().build();
110-
const getXAttributeMock = jest.fn();
111-
getXAttributeMock.mockReturnValueOnce(new EditableValueBuilder<Big>().withValue(new Big(1)).build());
112-
getXAttributeMock.mockReturnValueOnce(new EditableValueBuilder<Big>().withValue(new Big(2)).build());
113-
xAttribute.get = getXAttributeMock;
114-
115-
const yAttribute = new ListAttributeValueBuilder<Big>().build();
116-
const getYAttributeMock = jest.fn();
117-
getYAttributeMock.mockReturnValueOnce(new EditableValueBuilder<Big>().withValue(new Big(3)).build());
118-
getYAttributeMock.mockReturnValueOnce(new EditableValueBuilder<Big>().withValue(new Big(6)).build());
119-
yAttribute.get = getYAttributeMock;
107+
function setupBasicColumnSeries(overwriteConfig: Partial<SeriesType>): SeriesType {
108+
const basicSeries = setupBasicSeries(overwriteConfig) as SeriesType;
120109

121110
return {
122-
dataSet: "static",
123-
customSeriesOptions: overwriteConfig.customSeriesOptions ?? "",
124-
aggregationType: overwriteConfig.aggregationType ?? "avg",
125-
staticBarColor: overwriteConfig.staticBarColor ?? undefined,
126-
staticDataSource: list(2),
127-
staticXAttribute: xAttribute,
128-
staticYAttribute: yAttribute
111+
...basicSeries,
112+
staticBarColor: overwriteConfig.staticBarColor ?? undefined
129113
};
130114
}

0 commit comments

Comments
 (0)