1+ import { actionValue } from "@mendix/widget-plugin-test-utils" ;
12import { render } from "@testing-library/react" ;
23import { ActionValue , DynamicValue , ObjectItem } from "mendix" ;
34import { createElement } from "react" ;
@@ -15,10 +16,6 @@ const mockGetChannelName = getChannelNameModule.getChannelName as jest.MockedFun
1516> ;
1617const 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-
2219function 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