Update test, use destructuring to clean up code

This commit is contained in:
Matt Rider 2019-06-20 18:04:21 -03:00
parent be70088dd7
commit 51153ca870
2 changed files with 16 additions and 8 deletions

View File

@ -89,10 +89,16 @@ describe('ContributionForm.vue', () => {
})
describe('valid form submission', () => {
expectedParams = {
variables: { title: postTitle, content: postContent, language: 'en', id: null },
}
beforeEach(async () => {
expectedParams = {
variables: {
title: postTitle,
content: postContent,
language: 'en',
id: null,
imageUpload: null,
},
}
postTitleInput = wrapper.find('.ds-input')
postTitleInput.setValue('this is a title for a post')
wrapper.vm.updateEditorContent('this is a post')

View File

@ -88,7 +88,7 @@ export default {
form: {
title: '',
content: '',
teaserImage: '',
teaserImage: null,
language: null,
languageOptions: [],
},
@ -123,6 +123,7 @@ export default {
this.form.content = contribution.content
this.form.title = contribution.title
this.form.language = this.locale
this.form.teaserImage = contribution.imageUpload
},
},
error() {
@ -146,16 +147,17 @@ export default {
},
methods: {
submit() {
const { title, content, language, teaserImage } = this.form
this.loading = true
this.$apollo
.mutate({
mutation: this.id ? PostMutations().UpdatePost : PostMutations().CreatePost,
variables: {
id: this.id,
title: this.form.title,
content: this.form.content,
language: this.form.language ? this.form.language.value : this.$i18n.locale(),
imageUpload: this.form.teaserImage,
title,
content,
language: language ? language.value : this.$i18n.locale(),
imageUpload: teaserImage,
},
})
.then(res => {