mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add some component tests, rename files
- with new naming schema
This commit is contained in:
parent
ced676d315
commit
1930e5bafe
@ -16,20 +16,7 @@ describe('Editor.vue', () => {
|
|||||||
let mocks
|
let mocks
|
||||||
let getters
|
let getters
|
||||||
|
|
||||||
beforeEach(() => {
|
const Wrapper = () => {
|
||||||
propsData = {}
|
|
||||||
mocks = {
|
|
||||||
$t: () => {},
|
|
||||||
}
|
|
||||||
getters = {
|
|
||||||
'editor/placeholder': () => {
|
|
||||||
return 'some cool placeholder'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('mount', () => {
|
|
||||||
let Wrapper = () => {
|
|
||||||
const store = new Vuex.Store({
|
const store = new Vuex.Store({
|
||||||
getters,
|
getters,
|
||||||
})
|
})
|
||||||
@ -45,6 +32,20 @@ describe('Editor.vue', () => {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
propsData = {}
|
||||||
|
mocks = {
|
||||||
|
$t: () => {},
|
||||||
|
}
|
||||||
|
getters = {
|
||||||
|
'editor/placeholder': () => {
|
||||||
|
return 'some cool placeholder'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
it('renders', () => {
|
it('renders', () => {
|
||||||
expect(Wrapper().is('div')).toBe(true)
|
expect(Wrapper().is('div')).toBe(true)
|
||||||
})
|
})
|
||||||
@ -67,5 +68,31 @@ describe('Editor.vue', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('optional extensions', () => {
|
||||||
|
it('sets the Mention items to the users', () => {
|
||||||
|
propsData.users = [{ id: 'u345' }]
|
||||||
|
wrapper = Wrapper()
|
||||||
|
expect(wrapper.vm.editor.extensions.options.mention.items()).toEqual(propsData.users)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('mentions is not an option when there are no users', () => {
|
||||||
|
expect(wrapper.vm.editor.extensions.options).toEqual(
|
||||||
|
expect.not.objectContaining({ mention: expect.anything() }),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('sets the Hashtag items to the hashtags', () => {
|
||||||
|
propsData.hashtags = [{ id: 'Frieden' }]
|
||||||
|
wrapper = Wrapper()
|
||||||
|
expect(wrapper.vm.editor.extensions.options.hashtag.items()).toEqual(propsData.hashtags)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('hashtags is not an option when there are no hashtags', () => {
|
||||||
|
expect(wrapper.vm.editor.extensions.options).toEqual(
|
||||||
|
expect.not.objectContaining({ hashtag: expect.anything() }),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -212,7 +212,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
// Set array of optional extensions by analysing the props.
|
// Set array of optional extensions by analysing the props.
|
||||||
let optionalExtensions = []
|
let optionalExtensions = []
|
||||||
if (this.users) {
|
if (this.users && this.users.length) {
|
||||||
optionalExtensions.push(
|
optionalExtensions.push(
|
||||||
new Mention({
|
new Mention({
|
||||||
// a list of all suggested items
|
// a list of all suggested items
|
||||||
@ -287,7 +287,7 @@ export default {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (this.hashtags) {
|
if (this.hashtags && this.hashtags.length) {
|
||||||
optionalExtensions.push(
|
optionalExtensions.push(
|
||||||
new Hashtag({
|
new Hashtag({
|
||||||
// a list of all suggested items
|
// a list of all suggested items
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
import { config, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
||||||
import Notification from '.'
|
import Notification from './Notification'
|
||||||
import Styleguide from '@human-connection/styleguide'
|
import Styleguide from '@human-connection/styleguide'
|
||||||
import Filters from '~/plugins/vue-filters'
|
import Filters from '~/plugins/vue-filters'
|
||||||
|
|
||||||
@ -49,6 +49,10 @@ describe('Notification', () => {
|
|||||||
expect(Wrapper().text()).toContain("It's a title")
|
expect(Wrapper().text()).toContain("It's a title")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('renders the contentExcerpt', () => {
|
||||||
|
expect(Wrapper().text()).toContain('@jenny-rostock is the best')
|
||||||
|
})
|
||||||
|
|
||||||
it('has no class "read"', () => {
|
it('has no class "read"', () => {
|
||||||
expect(Wrapper().classes()).not.toContain('read')
|
expect(Wrapper().classes()).not.toContain('read')
|
||||||
})
|
})
|
||||||
@ -69,7 +69,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
hashParam() {
|
hashParam() {
|
||||||
// Wolle: console.log('this.post.id: ', this.post.id, 'this.comment.id: ', this.comment.id)
|
|
||||||
return this.post.id ? {} : { hash: `#commentId-${this.comment.id}` }
|
return this.post.id ? {} : { hash: `#commentId-${this.comment.id}` }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import { config, shallowMount, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
import { config, shallowMount, mount, createLocalVue, RouterLinkStub } from '@vue/test-utils'
|
||||||
import NotificationList from '.'
|
import NotificationList from './NotificationList'
|
||||||
import Notification from '../Notification'
|
import Notification from '../Notification/Notification'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import Filters from '~/plugins/vue-filters'
|
import Filters from '~/plugins/vue-filters'
|
||||||
|
|
||||||
@ -10,7 +10,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Notification from '../Notification'
|
import Notification from '../Notification/Notification'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'NotificationList',
|
name: 'NotificationList',
|
||||||
@ -1,13 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<ds-button
|
<ds-button v-if="totalNotifications <= 0" class="notifications-menu" disabled icon="bell">
|
||||||
v-if="totalNotifications <= 0"
|
{{ totalNotifications }}
|
||||||
class="notifications-menu"
|
</ds-button>
|
||||||
disabled
|
|
||||||
icon="bell"
|
|
||||||
>{{ totalNotifications }}</ds-button>
|
|
||||||
<dropdown v-else class="notifications-menu" :placement="placement">
|
<dropdown v-else class="notifications-menu" :placement="placement">
|
||||||
<template slot="default" slot-scope="{ toggleMenu }">
|
<template slot="default" slot-scope="{ toggleMenu }">
|
||||||
<ds-button primary icon="bell" @click.prevent="toggleMenu">{{ totalNotifications }}</ds-button>
|
<ds-button primary icon="bell" @click.prevent="toggleMenu">
|
||||||
|
{{ totalNotifications }}
|
||||||
|
</ds-button>
|
||||||
</template>
|
</template>
|
||||||
<template slot="popover">
|
<template slot="popover">
|
||||||
<div class="notifications-menu-popover">
|
<div class="notifications-menu-popover">
|
||||||
@ -18,7 +17,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import NotificationList from '../NotificationList'
|
import NotificationList from '../NotificationList/NotificationList'
|
||||||
import Dropdown from '~/components/Dropdown'
|
import Dropdown from '~/components/Dropdown'
|
||||||
import gql from 'graphql-tag'
|
import gql from 'graphql-tag'
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user