From 7b0541025e4c6579c3115ac22212758f219f663e Mon Sep 17 00:00:00 2001 From: Imran Ariffin Date: Sun, 26 Jan 2020 14:43:31 -0500 Subject: [PATCH] Feature #83: Do not display set status for goals (#86) * Do not display set status for goals * Add tests to logger service --- .../ItemActions/__tests__/presenters.test.js | 22 ++++++++++++++++++ app/components/ItemActions/presenters.js | 2 +- app/services/logger/__tests__/logger.test.js | 23 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 app/services/logger/__tests__/logger.test.js diff --git a/app/components/ItemActions/__tests__/presenters.test.js b/app/components/ItemActions/__tests__/presenters.test.js index 0ffd546..b2c5630 100644 --- a/app/components/ItemActions/__tests__/presenters.test.js +++ b/app/components/ItemActions/__tests__/presenters.test.js @@ -50,6 +50,28 @@ describe('ItemActions presenters', () => { expect(window.console.error.mock.calls).toEqual([]) }) + test('do not display set status for goals', () => { + ownProps = { ...ownProps, type: 'goal' } + + props = { + ...ownProps, + ...mapStateToProps(state, ownProps), + ...mapDispatchToProps(dispatch, ownProps) + } + + expect(props.shouldDisplaySetStatus).toEqual(false) + + ownProps = { ...ownProps, type: 'task' } + + props = { + ...ownProps, + ...mapStateToProps(state, ownProps), + ...mapDispatchToProps(dispatch, ownProps) + } + + expect(props.shouldDisplaySetStatus).toEqual(true) + }) + test('provide correct on delete callback', () => { ownProps = { ...ownProps, type: 'goal' } props = { diff --git a/app/components/ItemActions/presenters.js b/app/components/ItemActions/presenters.js index 8045acb..1c60980 100644 --- a/app/components/ItemActions/presenters.js +++ b/app/components/ItemActions/presenters.js @@ -10,7 +10,7 @@ export const mapStateToProps = (state, ownProps) => { task: tasksSelectors.getById }[type](itemId)(state) const itemStatus = (item && item.status) || '' - const shouldDisplaySetStatus = tasksSelectors.isInnermost(state, itemId) + const shouldDisplaySetStatus = type === 'task' && tasksSelectors.isInnermost(state, itemId) return { shouldDisplaySetStatus, diff --git a/app/services/logger/__tests__/logger.test.js b/app/services/logger/__tests__/logger.test.js new file mode 100644 index 0000000..8a99e45 --- /dev/null +++ b/app/services/logger/__tests__/logger.test.js @@ -0,0 +1,23 @@ +/* eslint-env jest */ + +import logger from 'ss/services/logger' + +describe('logger services', () => { + beforeEach(() => { + jest.spyOn(window.console, 'log') + window.console.log.mockImplementation(() => {}) + window.console.log.mockClear() + }) + + test('log using console log', () => { + logger.log('a') + + expect(window.console.log.mock.calls).toEqual([['a']]) + }) + + test('support variable arguments', () => { + logger.log('a', 'b', 1, [], {}) + + expect(window.console.log.mock.calls).toEqual([['a', 'b', 1, [], {}]]) + }) +})