diff --git a/components/x-interaction/__tests__/x-interaction.test.jsx b/components/x-interaction/__tests__/x-interaction.test.jsx
index 5951b0c36..ce8b0136c 100644
--- a/components/x-interaction/__tests__/x-interaction.test.jsx
+++ b/components/x-interaction/__tests__/x-interaction.test.jsx
@@ -202,23 +202,42 @@ describe('x-interaction', () => {
).toBe(15);
});
- it('should pass actions to actionsRef on mount and null on unmount', async () => {
- const actionsRef = jest.fn();
+ describe('actionsRef', () => {
+ it('should pass actions to actionsRef on mount and null on unmount', async () => {
+ const actionsRef = jest.fn();
- const Base = () => null;
- const Wrapped = withActions({
- foo() {},
- })(Base);
+ const Base = () => null;
+ const Wrapped = withActions({
+ foo() {},
+ })(Base);
+
+ const target = mount();
- const target = mount();
+ expect(actionsRef).toHaveBeenCalled();
+ expect(actionsRef.mock.calls[0][0]).toHaveProperty('foo');
- expect(actionsRef).toHaveBeenCalled();
- expect(actionsRef.mock.calls[0][0]).toHaveProperty('foo');
+ target.unmount();
- target.unmount();
+ expect(actionsRef).toHaveBeenLastCalledWith(null);
+ });
- expect(actionsRef).toHaveBeenLastCalledWith(null);
- });
+ it('should pass all actions for rewrapped components', async () => {
+ const actionsRef = jest.fn();
+
+ const Base = () => null;
+ const Wrapped = withActions({
+ bar() {},
+ })(withActions({
+ foo() {},
+ })(Base));
+
+ const target = mount();
+
+ expect(actionsRef).toHaveBeenCalled();
+ expect(actionsRef.mock.calls[0][0]).toHaveProperty('foo');
+ expect(actionsRef.mock.calls[0][0]).toHaveProperty('bar');
+ });
+ });
it(`shouldn't reset props when others change`, async () => {
const Base = () => null;
diff --git a/components/x-interaction/src/Interaction.jsx b/components/x-interaction/src/Interaction.jsx
index a864d257d..1689210ba 100644
--- a/components/x-interaction/src/Interaction.jsx
+++ b/components/x-interaction/src/Interaction.jsx
@@ -18,9 +18,10 @@ export const withActions = (getActions) => (Component) => {
// to wrap it further. so, discard its wrapper and rewrap the original
// component with the new actions on top
if(Component._wraps) {
+ const wrappedGetActions = Component._wraps.getActions;
Component = Component._wraps.Component;
getActions = initialState => Object.assign(
- invoke(Component._wraps.getActions, initialState),
+ invoke(wrappedGetActions, initialState),
invoke(_wraps.getActions, initialState)
);
}