Skip to content

Commit 2b63b4b

Browse files
committed
refactor(pusher-web): use actionValue() builder in tests; fix grammar in release script comment
1 parent 3cdb16d commit 2b63b4b

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

packages/modules/pusher/scripts/release.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async function main(): Promise<void> {
2525
createModuleMpk,
2626
addWidgetsToMpk,
2727
// Copy old legacy widget to the module, so we have both for easy migration.
28-
// New widgets has different filename: com.mendix.widget.web.Pusher.mpk, they won't clash.
28+
// New widget has a different filename: com.mendix.widget.web.Pusher.mpk, they won't clash.
2929
addTestProjectWidgetsToMpk(["Pusher.mpk"]),
3030
moveModuleToDist
3131
]

packages/pluggableWidgets/pusher-web/src/__tests__/Pusher.spec.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { actionValue } from "@mendix/widget-plugin-test-utils";
12
import { render } from "@testing-library/react";
23
import { ActionValue, DynamicValue, ObjectItem } from "mendix";
34
import { createElement } from "react";
@@ -15,10 +16,6 @@ const mockGetChannelName = getChannelNameModule.getChannelName as jest.MockedFun
1516
>;
1617
const mockUsePusherSubscribe = usePusherSubscribeModule.usePusherSubscribe as jest.Mock;
1718

18-
function makeAction(canExecute = true): ActionValue {
19-
return { canExecute, execute: jest.fn(), isExecuting: false } as unknown as ActionValue;
20-
}
21-
2219
function makeProps(channelName: string | undefined, handlers: Array<{ actionName: string; action: ActionValue }>) {
2320
mockGetChannelName.mockReturnValue(channelName);
2421
return {
@@ -35,7 +32,7 @@ describe("Pusher", () => {
3532
});
3633

3734
it("passes undefined subscription when channelName is undefined", () => {
38-
render(createElement(Pusher, makeProps(undefined, [{ actionName: "update", action: makeAction() }])));
35+
render(createElement(Pusher, makeProps(undefined, [{ actionName: "update", action: actionValue() }])));
3936

4037
expect(mockUsePusherSubscribe).toHaveBeenCalledWith(undefined);
4138
});
@@ -47,7 +44,7 @@ describe("Pusher", () => {
4744
});
4845

4946
it("passes subscription with correct channelName and eventBindings", () => {
50-
const action = makeAction();
47+
const action = actionValue();
5148
render(createElement(Pusher, makeProps("private-Entity.123", [{ actionName: "update", action }])));
5249

5350
expect(mockUsePusherSubscribe).toHaveBeenCalledWith(
@@ -59,7 +56,7 @@ describe("Pusher", () => {
5956
});
6057

6158
it("calls executeAction when onEvent fires", () => {
62-
const action = makeAction();
59+
const action = actionValue();
6360
render(createElement(Pusher, makeProps("private-Entity.123", [{ actionName: "update", action }])));
6461

6562
const { eventBindings } = mockUsePusherSubscribe.mock.calls[0][0];

0 commit comments

Comments
 (0)