diff --git a/src/containers/ListView/TableAction.jsx b/src/containers/ListView/TableAction.jsx index 44886d3f..40a800e1 100644 --- a/src/containers/ListView/TableAction.jsx +++ b/src/containers/ListView/TableAction.jsx @@ -11,6 +11,7 @@ export const TableAction = ({ tableInstance, handleClick }) => ( onClick={handleClick(tableInstance.rows)} variant="primary" className="view-all-responses-btn" + disabled={tableInstance.rows.length === 0} > diff --git a/src/containers/ListView/TableAction.test.jsx b/src/containers/ListView/TableAction.test.jsx index 4ecf9f22..5adef4cd 100644 --- a/src/containers/ListView/TableAction.test.jsx +++ b/src/containers/ListView/TableAction.test.jsx @@ -13,6 +13,15 @@ describe('TableAction component', () => { expect(el.snapshot).toMatchSnapshot(); }); + test('Inactive Button "View All Responses"', () => { + const emptyProps = { + tableInstance: { rows: [] }, + handleClick: jest.fn(), + }; + const el = shallow(); + expect(el.snapshot).toMatchSnapshot(); + }); + test('handleClick', () => { shallow(); expect(props.handleClick).toHaveBeenCalledWith(props.tableInstance.rows); diff --git a/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap b/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap index 5b314467..8867be0b 100644 --- a/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap +++ b/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap @@ -1,8 +1,23 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`TableAction component Inactive Button "View All Responses" 1`] = ` + +`; + exports[`TableAction component snapshots 1`] = `