feat: update returnToUnit to include api response (#346)
This commit is contained in:
@@ -70,7 +70,7 @@ export const saveBlock = ({ content, returnToUnit }) => (dispatch) => {
|
||||
content,
|
||||
onSuccess: (response) => {
|
||||
dispatch(actions.app.setSaveResponse(response));
|
||||
returnToUnit();
|
||||
returnToUnit(response.data)();
|
||||
},
|
||||
}));
|
||||
};
|
||||
|
||||
@@ -138,7 +138,7 @@ describe('app thunkActions', () => {
|
||||
let returnToUnit;
|
||||
let calls;
|
||||
beforeEach(() => {
|
||||
returnToUnit = jest.fn();
|
||||
returnToUnit = jest.fn((response) => () => response);
|
||||
thunkActions.saveBlock({ content: testValue, returnToUnit })(dispatch);
|
||||
calls = dispatch.mock.calls;
|
||||
});
|
||||
|
||||
@@ -21,12 +21,12 @@ export const navigateCallback = ({
|
||||
destination,
|
||||
analyticsEvent,
|
||||
analytics,
|
||||
}) => () => {
|
||||
}) => (response) => {
|
||||
if (process.env.NODE_ENV !== 'development' && analyticsEvent && analytics) {
|
||||
sendTrackEvent(analyticsEvent, analytics);
|
||||
}
|
||||
if (returnFunction) {
|
||||
returnFunction();
|
||||
returnFunction()(response);
|
||||
return;
|
||||
}
|
||||
module.navigateTo(destination);
|
||||
|
||||
@@ -74,7 +74,6 @@ describe('hooks', () => {
|
||||
let output;
|
||||
const SAVED_ENV = process.env;
|
||||
const destination = 'hOmE';
|
||||
const returnFunction = jest.fn();
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
process.env = { ...SAVED_ENV };
|
||||
@@ -102,6 +101,7 @@ describe('hooks', () => {
|
||||
expect(spy).toHaveBeenCalledWith(destination);
|
||||
});
|
||||
it('should call returnFunction and return null', () => {
|
||||
const returnFunction = jest.fn(() => (response) => response);
|
||||
output = hooks.navigateCallback({
|
||||
destination,
|
||||
returnFunction,
|
||||
|
||||
Reference in New Issue
Block a user