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

@ -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,11 +32,11 @@ describe('PostSlug', () => {
// }, // },
$toast: { $toast: {
success: () => {}, success: () => {},
error: () => {} error: () => {},
}, },
$apollo: { $apollo: {
mutate: jest.fn().mockResolvedValue() mutate: jest.fn().mockResolvedValue(),
} },
} }
}) })