Skip to content

Commit

Permalink
Feature #83: Do not display set status for goals (#86)
Browse files Browse the repository at this point in the history
* Do not display set status for goals

* Add tests to logger service
  • Loading branch information
imranariffin authored Jan 26, 2020
1 parent 56cb499 commit 7b05410
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
22 changes: 22 additions & 0 deletions app/components/ItemActions/__tests__/presenters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion app/components/ItemActions/presenters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
23 changes: 23 additions & 0 deletions app/services/logger/__tests__/logger.test.js
Original file line number Diff line number Diff line change
@@ -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, [], {}]])
})
})

0 comments on commit 7b05410

Please sign in to comment.