Browse Source

Add unit test for container/ProjectCreationButton

pull/341/head
Hironsan 5 years ago
parent
commit
0cdfd70aaa
2 changed files with 42 additions and 3 deletions
  1. 5
      frontend/components/containers/ProjectCreationButton.vue
  2. 40
      frontend/test/unit/components/containers/ProjectCreationButton.spec.js

5
frontend/components/containers/ProjectCreationButton.vue

@ -20,6 +20,7 @@
</template>
<script>
import { mapActions } from 'vuex'
import ProjectCreationForm from '@/components/organisms/ProjectCreationForm'
export default {
@ -34,9 +35,7 @@ export default {
},
methods: {
createProject(payload) {
return this.$store.dispatch('projects/createProject', payload)
}
...mapActions('projects', ['createProject'])
}
}
</script>

40
frontend/test/unit/components/containers/ProjectCreationButton.spec.js

@ -0,0 +1,40 @@
import { shallowMount, createLocalVue } from '@vue/test-utils'
import Vue from 'vue'
import Vuex from 'vuex'
import Vuetify from 'vuetify'
import ProjectCreationButton from '@/components/containers/ProjectCreationButton'
const localVue = createLocalVue()
localVue.use(Vuex)
Vue.use(Vuetify)
describe('ProjectCreationButtonContainer', () => {
let store
let projects
let actions
let mutations
beforeEach(() => {
actions = {
createProject: jest.fn()
}
mutations = {}
projects = {
namespaced: true,
actions,
mutations,
state: {}
}
store = new Vuex.Store({
modules: {
projects
}
})
})
test('called createProject action', () => {
const wrapper = shallowMount(ProjectCreationButton, { store, localVue })
wrapper.vm.createProject()
expect(actions.createProject).toHaveBeenCalled()
})
})
Loading…
Cancel
Save