Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #558 from hackaru-app/no-project
Browse files Browse the repository at this point in the history
Add no project to select tag
  • Loading branch information
ktmouk authored May 15, 2021
2 parents e2e9e7b + 265ae95 commit d4e2f55
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
22 changes: 17 additions & 5 deletions __tests__/src/renderer/components/molecules/project-select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ describe('ProjectSelect', () => {
propsData: {
projects: [
{
id: 1,
name: 'Development',
color: '#f00',
id: null,
name: 'No Project',
color: '#cccfd9',
},
{
id: 2,
id: 1,
name: 'Review',
color: '#ff0',
},
Expand All @@ -30,7 +30,19 @@ describe('ProjectSelect', () => {
})

it('emits input', () => {
expect(wrapper.emitted('input')[0][0]).toBe(2)
expect(wrapper.emitted('input')[0][0]).toBe(1)
})
})

describe('when select no-project', () => {
beforeEach(async () => {
wrapper = factory()
await wrapper.setProps({ value: 1 })
wrapper.find(testId('select')).findAll('option').at(0).setSelected()
})

it('emits input', () => {
expect(wrapper.emitted('input')[0][0]).toBeNull()
})
})
})
3 changes: 2 additions & 1 deletion src/renderer/components/molecules/project-select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ export default {
},
methods: {
change(e) {
this.$emit('input', Number(e.target.value))
const id = e.target.value
this.$emit('input', id ? Number(id) : null)
},
},
}
Expand Down
7 changes: 6 additions & 1 deletion src/renderer/components/organisms/timer-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@ export default {
computed: {
...mapGetters({
activity: 'activities/working',
projects: 'projects/all',
}),
projects() {
return [
{ id: null, name: 'No Project', color: '#cccfd9' },
...this.$store.getters['projects/all'],
]
},
working() {
return !!this.activity
},
Expand Down

0 comments on commit d4e2f55

Please sign in to comment.