Lint fixes

This commit is contained in:
Wolfgang Huß 2019-05-27 12:39:37 +02:00
parent 68980f85c6
commit f9fe4f742f
11 changed files with 163 additions and 167 deletions

View File

@ -84,7 +84,7 @@ export default {
` `
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: gqlMutation, mutation: gqlMutation,
variables: { id: this.comment.id } variables: { id: this.comment.id },
}) })
this.$toast.success(this.$t(`delete.comment.success`)) this.$toast.success(this.$t(`delete.comment.success`))
this.$emit('deleteComment') this.$emit('deleteComment')
@ -92,6 +92,6 @@ export default {
this.$toast.error(err.message) this.$toast.error(err.message)
} }
}, },
} },
} }
</script> </script>

View File

@ -59,7 +59,7 @@ export default {
required: true, required: true,
validator: value => { validator: value => {
return value.match(/(contribution|comment|organization|user)/) return value.match(/(contribution|comment|organization|user)/)
} },
}, },
callbacks: { type: Object, required: true }, callbacks: { type: Object, required: true },
}, },
@ -101,7 +101,7 @@ export default {
callback: () => { callback: () => {
this.openModal('delete') this.openModal('delete')
}, },
icon: 'trash' icon: 'trash',
}) })
} }
@ -153,8 +153,8 @@ export default {
data: { data: {
type: this.resourceType, type: this.resourceType,
resource: this.resource, resource: this.resource,
callbacks: this.callbacks callbacks: this.callbacks,
} },
}) })
}, },
}, },

View File

@ -24,7 +24,7 @@ describe('DeleteModal.vue', () => {
id: 'p23', id: 'p23',
callbacks: { callbacks: {
confirm: () => Post.methods.deletePostCallback('list'), confirm: () => Post.methods.deletePostCallback('list'),
cancel: null cancel: null,
}, },
} }
mocks = { mocks = {
@ -65,7 +65,7 @@ describe('DeleteModal.vue', () => {
name: 'It is a post', name: 'It is a post',
callbacks: { callbacks: {
confirm: () => Post.methods.deletePostCallback('list'), confirm: () => Post.methods.deletePostCallback('list'),
cancel: null cancel: null,
}, },
} }
}) })
@ -73,9 +73,7 @@ describe('DeleteModal.vue', () => {
it('mentions post title', () => { it('mentions post title', () => {
Wrapper() Wrapper()
const calls = mocks.$t.mock.calls const calls = mocks.$t.mock.calls
const expected = [ const expected = [['delete.contribution.message', { name: 'It is a post' }]]
['delete.contribution.message', { name: 'It is a post' }]
]
expect(calls).toEqual(expect.arrayContaining(expected)) expect(calls).toEqual(expect.arrayContaining(expected))
}) })
}) })
@ -88,17 +86,15 @@ describe('DeleteModal.vue', () => {
name: 'It is the user of the comment', name: 'It is the user of the comment',
callbacks: { callbacks: {
confirm: () => Post.methods.deletePostCallback('list'), confirm: () => Post.methods.deletePostCallback('list'),
cancel: null cancel: null,
} },
} }
}) })
it('mentions comments user name', () => { it('mentions comments user name', () => {
Wrapper() Wrapper()
const calls = mocks.$t.mock.calls const calls = mocks.$t.mock.calls
const expected = [ const expected = [['delete.comment.message', { name: 'It is the user of the comment' }]]
['delete.comment.message', { name: 'It is the user of the comment' }]
]
expect(calls).toEqual(expect.arrayContaining(expected)) expect(calls).toEqual(expect.arrayContaining(expected))
}) })
}) })
@ -122,7 +118,7 @@ describe('DeleteModal.vue', () => {
id: 'p23', id: 'p23',
callbacks: { callbacks: {
confirm: () => Post.methods.deletePostCallback('list'), confirm: () => Post.methods.deletePostCallback('list'),
cancel: null cancel: null,
}, },
} }
wrapper = Wrapper() wrapper = Wrapper()
@ -195,8 +191,8 @@ describe('DeleteModal.vue', () => {
id: 'c3', id: 'c3',
callbacks: { callbacks: {
confirm: () => Post.methods.deletePostCallback('list'), confirm: () => Post.methods.deletePostCallback('list'),
cancel: null cancel: null,
} },
} }
wrapper = Wrapper() wrapper = Wrapper()
}) })

View File

@ -74,7 +74,7 @@ export default {
}, },
methods: { methods: {
async cancel() { async cancel() {
if (!!this.callbacks.cancel) { if (this.callbacks.cancel) {
await this.callbacks.cancel() await this.callbacks.cancel()
} }
this.isOpen = false this.isOpen = false
@ -85,7 +85,7 @@ export default {
async confirm() { async confirm() {
this.loading = true this.loading = true
try { try {
if (!!this.callbacks.confirm) { if (this.callbacks.confirm) {
await this.callbacks.confirm() await this.callbacks.confirm()
} }
this.success = true this.success = true

View File

@ -55,7 +55,7 @@ export default {
}, },
methods: { methods: {
async cancel() { async cancel() {
if (!!this.callbacks.cancel) { if (this.callbacks.cancel) {
await this.callbacks.cancel() await this.callbacks.cancel()
} }
this.isOpen = false this.isOpen = false
@ -65,7 +65,7 @@ export default {
}, },
async confirm() { async confirm() {
try { try {
if (!!this.callbacks.confirm) { if (this.callbacks.confirm) {
await this.callbacks.confirm() await this.callbacks.confirm()
} }
await this.$apollo.mutate({ await this.$apollo.mutate({

View File

@ -74,7 +74,7 @@ export default {
}, },
methods: { methods: {
async cancel() { async cancel() {
if (!!this.callbacks.cancel) { if (this.callbacks.cancel) {
await this.callbacks.cancel() await this.callbacks.cancel()
} }
this.isOpen = false this.isOpen = false
@ -85,7 +85,7 @@ export default {
async confirm() { async confirm() {
this.loading = true this.loading = true
try { try {
if (!!this.callbacks.confirm) { if (this.callbacks.confirm) {
await this.callbacks.confirm() await this.callbacks.confirm()
} }
await this.$apollo.mutate({ await this.$apollo.mutate({

View File

@ -1,16 +1,16 @@
<template> <template>
<ds-card <ds-card
:header="post.title" :header="post.title"
:image="post.image" :image="post.image"
:class="{'post-card': true, 'disabled-content': post.disabled}" :class="{'post-card': true, 'disabled-content': post.disabled}"
>
<!-- Post Link Target -->
<nuxt-link
class="post-link"
:to="{ name: 'post-id-slug', params: { id: post.id, slug: post.slug } }"
> >
<!-- Post Link Target --> {{ post.title }}
<nuxt-link </nuxt-link>
class="post-link"
:to="{ name: 'post-id-slug', params: { id: post.id, slug: post.slug } }"
>
{{ post.title }}
</nuxt-link>
<ds-space margin-bottom="small" /> <ds-space margin-bottom="small" />
<!-- Username, Image & Date of Post --> <!-- Username, Image & Date of Post -->
<div> <div>
@ -74,7 +74,7 @@
</div> </div>
</no-ssr> </no-ssr>
</template> </template>
</ds-card> </ds-card>
</template> </template>
<script> <script>
@ -102,7 +102,7 @@ export default {
}, },
width: { width: {
type: Object, type: Object,
default: () => {} default: () => {},
}, },
}, },
computed: { computed: {

View File

@ -14,7 +14,7 @@ export default {
` `
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: gqlMutation, mutation: gqlMutation,
variables: { id: this.post.id } variables: { id: this.post.id },
}) })
this.$toast.success(this.$t(`delete.contribution.success`)) this.$toast.success(this.$t(`delete.contribution.success`))
switch (postDisplayType) { switch (postDisplayType) {
@ -30,6 +30,6 @@ export default {
} catch (err) { } catch (err) {
this.$toast.error(err.message) this.$toast.error(err.message)
} }
} },
} },
} }

View File

@ -2,7 +2,7 @@ import { shallowMount, mount, createLocalVue } from '@vue/test-utils'
import Methods from '~/mixins/PostMutationHelpers' import Methods from '~/mixins/PostMutationHelpers'
const { const {
methods: { deletePostCallback } methods: { deletePostCallback },
} = Methods } = Methods
// console.log(deletePostCallback()) // console.log(deletePostCallback())
@ -12,26 +12,26 @@ describe('PostMutationHelpers.js', () => {
beforeEach(() => { beforeEach(() => {
post = { post = {
id: 'p23' id: 'p23',
} }
mocks = { mocks = {
$t: jest.fn(), $t: jest.fn(),
$filters: { $filters: {
truncate: a => a truncate: a => a,
}, },
$emit: jest.fn(), $emit: jest.fn(),
$router: { $router: {
history: { history: {
push: jest.fn() push: jest.fn(),
} },
}, },
$toast: { $toast: {
success: () => {}, success: () => {},
error: () => {} error: () => {},
}, },
$apollo: { $apollo: {
mutate: jest.fn().mockResolvedValue() mutate: jest.fn().mockResolvedValue(),
} },
} }
}) })

View File

@ -76,7 +76,7 @@ export default {
methods: { methods: {
deletePost(index) { deletePost(index) {
this.post.relatedContributions.splice(index, 1) this.post.relatedContributions.splice(index, 1)
} },
}, },
apollo: { apollo: {
Post: { Post: {

View File

@ -24,7 +24,7 @@ describe('PostSlug', () => {
propsData = {} propsData = {}
mocks = { mocks = {
post: { post: {
id: 'p23' id: 'p23',
}, },
$t: jest.fn(), $t: jest.fn(),
// $filters: { // $filters: {
@ -32,76 +32,76 @@ describe('PostSlug', () => {
// }, // },
$toast: { $toast: {
success: () => {}, success: () => {},
error: () => {} error: () => {},
}, },
$apollo: { $apollo: {
mutate: jest.fn().mockResolvedValue() mutate: jest.fn().mockResolvedValue(),
} },
} }
}) })
// describe('shallowMount', () => { // describe('shallowMount', () => {
// Wrapper = () => { // Wrapper = () => {
// return shallowMount(PostSlug, { propsData, mocks, localVue, router }) // return shallowMount(PostSlug, { propsData, mocks, localVue, router })
// } // }
// describe('defaults', () => { // describe('defaults', () => {
// it('success false', () => { // it('success false', () => {
// console.log(Wrapper().vm) // console.log(Wrapper().vm)
// expect(Wrapper().vm.success).toBe(false) // expect(Wrapper().vm.success).toBe(false)
// }) // })
// it('loading false', () => { // it('loading false', () => {
// expect(Wrapper().vm.loading).toBe(false) // expect(Wrapper().vm.loading).toBe(false)
// }) // })
// }) // })
// describe('given a post', () => { // describe('given a post', () => {
// beforeEach(() => { // beforeEach(() => {
// propsData = { // propsData = {
// type: 'contribution', // type: 'contribution',
// id: 'p23', // id: 'p23',
// name: 'It is a post' // name: 'It is a post'
// // callbacks: { // // callbacks: {
// // confirm: () => Post.methods.deletePostCallback('list'), // // confirm: () => Post.methods.deletePostCallback('list'),
// // cancel: null // // cancel: null
// // } // // }
// } // }
// }) // })
// it('mentions post title', () => { // it('mentions post title', () => {
// Wrapper() // Wrapper()
// const calls = mocks.$t.mock.calls // const calls = mocks.$t.mock.calls
// const expected = [ // const expected = [
// ['delete.contribution.message', { name: 'It is a post' }] // ['delete.contribution.message', { name: 'It is a post' }]
// ] // ]
// expect(calls).toEqual(expect.arrayContaining(expected)) // expect(calls).toEqual(expect.arrayContaining(expected))
// }) // })
// }) // })
// describe('given a comment', () => { // describe('given a comment', () => {
// beforeEach(() => { // beforeEach(() => {
// propsData = { // propsData = {
// type: 'comment', // type: 'comment',
// id: 'c3', // id: 'c3',
// name: 'It is the user of the comment' // name: 'It is the user of the comment'
// // callbacks: { // // callbacks: {
// // confirm: () => Post.methods.deletePostCallback('list'), // // confirm: () => Post.methods.deletePostCallback('list'),
// // cancel: null // // cancel: null
// // } // // }
// } // }
// }) // })
// it('mentions comments user name', () => { // it('mentions comments user name', () => {
// Wrapper() // Wrapper()
// const calls = mocks.$t.mock.calls // const calls = mocks.$t.mock.calls
// const expected = [ // const expected = [
// ['delete.comment.message', { name: 'It is the user of the comment' }] // ['delete.comment.message', { name: 'It is the user of the comment' }]
// ] // ]
// expect(calls).toEqual(expect.arrayContaining(expected)) // expect(calls).toEqual(expect.arrayContaining(expected))
// }) // })
// }) // })
// }) // })
describe('mount', () => { describe('mount', () => {
Wrapper = () => { Wrapper = () => {
@ -169,75 +169,75 @@ describe('PostSlug', () => {
// }) // })
// }) // })
// describe('click confirm button and delete the post', () => { // describe('click confirm button and delete the post', () => {
// beforeEach(() => { // beforeEach(() => {
// wrapper.find('button.confirm').trigger('click') // wrapper.find('button.confirm').trigger('click')
// }) // })
// it('calls delete mutation', () => { // it('calls delete mutation', () => {
// expect(mocks.$apollo.mutate).toHaveBeenCalled() // expect(mocks.$apollo.mutate).toHaveBeenCalled()
// }) // })
// it('sets success', () => { // it('sets success', () => {
// expect(wrapper.vm.success).toBe(true) // expect(wrapper.vm.success).toBe(true)
// }) // })
// it('displays a success message', () => { // it('displays a success message', () => {
// const calls = mocks.$t.mock.calls // const calls = mocks.$t.mock.calls
// const expected = [['delete.contribution.success']] // const expected = [['delete.contribution.success']]
// expect(calls).toEqual(expect.arrayContaining(expected)) // expect(calls).toEqual(expect.arrayContaining(expected))
// }) // })
// describe('after timeout', () => { // describe('after timeout', () => {
// beforeEach(jest.runAllTimers) // beforeEach(jest.runAllTimers)
// it('fades away', () => { // it('fades away', () => {
// expect(wrapper.vm.isOpen).toBe(false) // expect(wrapper.vm.isOpen).toBe(false)
// }) // })
// it('emits close', () => { // it('emits close', () => {
// expect(wrapper.emitted().close).toBeTruthy() // expect(wrapper.emitted().close).toBeTruthy()
// }) // })
// it('resets success', () => { // it('resets success', () => {
// expect(wrapper.vm.success).toBe(false) // expect(wrapper.vm.success).toBe(false)
// }) // })
// }) // })
// }) // })
}) })
// describe('given comment id', () => { // describe('given comment id', () => {
// beforeEach(() => { // beforeEach(() => {
// propsData = { // propsData = {
// type: 'comment', // type: 'comment',
// id: 'c3' // id: 'c3'
// // callbacks: { // // callbacks: {
// // confirm: () => Post.methods.deletePostCallback('list'), // // confirm: () => Post.methods.deletePostCallback('list'),
// // cancel: null // // cancel: null
// // } // // }
// } // }
// wrapper = Wrapper() // wrapper = Wrapper()
// }) // })
// describe('click confirm button and delete the comment', () => { // describe('click confirm button and delete the comment', () => {
// beforeEach(() => { // beforeEach(() => {
// wrapper.find('button.confirm').trigger('click') // wrapper.find('button.confirm').trigger('click')
// }) // })
// it('calls delete mutation', () => { // it('calls delete mutation', () => {
// expect(mocks.$apollo.mutate).toHaveBeenCalled() // expect(mocks.$apollo.mutate).toHaveBeenCalled()
// }) // })
// it('sets success', () => { // it('sets success', () => {
// expect(wrapper.vm.success).toBe(true) // expect(wrapper.vm.success).toBe(true)
// }) // })
// it('displays a success message', () => { // it('displays a success message', () => {
// const calls = mocks.$t.mock.calls // const calls = mocks.$t.mock.calls
// const expected = [['delete.comment.success']] // const expected = [['delete.comment.success']]
// expect(calls).toEqual(expect.arrayContaining(expected)) // expect(calls).toEqual(expect.arrayContaining(expected))
// }) // })
// }) // })
// }) // })
}) })
}) })