Skip to content

Commit c3ea4d3

Browse files
sakshamarora1kpsherva
authored andcommitted
frontsite: SelfCheckout: state: Fix searchItem action
1 parent c6ea79c commit c3ea4d3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/lib/pages/frontsite/SelfCheckout/state/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const notifyResultMessage = (message) => {
2222

2323
const searchItem = async (dispatch, term) => {
2424
const response = await itemApi.list(itemApi.query().withBarcode(term).qs());
25-
const item = _first(response.data.hits);
25+
const item = _first(response.data.hits) || {};
2626

2727
dispatch({
2828
type: SEARCH_ITEM_SUCCESS,

src/lib/pages/frontsite/SelfCheckout/state/actions.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ import { itemApi } from '@api/items';
77
const middlewares = [thunk];
88
const mockStore = configureMockStore(middlewares);
99

10-
const mockGet = jest.fn();
11-
itemApi.get = mockGet;
10+
const mockList = jest.fn();
11+
itemApi.list = mockList;
1212

1313
const response = { data: {} };
1414
const expectedPayload = {};
1515

1616
let store;
1717
beforeEach(() => {
18-
mockGet.mockClear();
18+
mockList.mockClear();
1919

2020
store = mockStore(initialState);
2121
store.clearActions();
2222
});
2323

2424
describe('SelfCheck Out test', () => {
2525
it('should dispatch an action updating the payloadresult item', async () => {
26-
mockGet.mockResolvedValue(response);
26+
mockList.mockResolvedValue(response);
2727

2828
const expectedAction1 = {
2929
type: actions.SEARCH_IS_LOADING,

0 commit comments

Comments
 (0)