mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
test: specs is not ok
This commit is contained in:
parent
73b005a900
commit
00c0397919
@ -68,7 +68,7 @@ describe('Comment.vue', () => {
|
|||||||
id: '2',
|
id: '2',
|
||||||
contentExcerpt: 'Hello I am a comment content',
|
contentExcerpt: 'Hello I am a comment content',
|
||||||
content: 'Hello I am comment content',
|
content: 'Hello I am comment content',
|
||||||
author: { id: 'commentAuthorId', slug: 'ogerly'}
|
author: { id: 'commentAuthorId', slug: 'ogerly' },
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -202,21 +202,21 @@ describe('Comment.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('click reply button', () => {
|
describe('click reply button', () => {
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
await wrapper.find('.reply-button').trigger('click')
|
await wrapper.find('.reply-button').trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('emits "reply"', () => {
|
it('emits "reply"', () => {
|
||||||
expect(wrapper.emitted('reply')).toEqual([
|
expect(wrapper.emitted('reply')).toEqual([
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
id: 'commentAuthorId',
|
id: 'commentAuthorId',
|
||||||
slug: 'ogerly'
|
slug: 'ogerly',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -76,7 +76,6 @@ import HcCommentForm from '~/components/CommentForm/CommentForm'
|
|||||||
import CommentMutations from '~/graphql/CommentMutations'
|
import CommentMutations from '~/graphql/CommentMutations'
|
||||||
import scrollToAnchor from '~/mixins/scrollToAnchor.js'
|
import scrollToAnchor from '~/mixins/scrollToAnchor.js'
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [scrollToAnchor],
|
mixins: [scrollToAnchor],
|
||||||
data() {
|
data() {
|
||||||
|
|||||||
@ -102,23 +102,22 @@ describe('CommentList.vue', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
describe('Comment', () => {
|
describe('Comment', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
|
})
|
||||||
|
it.only('Comment emitted reply()', () => {
|
||||||
|
wrapper.find('.comment-tag').vm.$emit('reply')
|
||||||
|
expect(wrapper.emitted('reply')).toEqual([
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id: 'commentAuthorId',
|
||||||
|
slug: 'ogerly',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Comment emitted reply()', () => {
|
|
||||||
wrapper.find('.comment-tag').vm.$emit('reply')
|
|
||||||
expect(wrapper.emitted('reply')).toEqual([
|
|
||||||
[
|
|
||||||
{
|
|
||||||
id: 'commentAuthorId',
|
|
||||||
slug: 'ogerly'
|
|
||||||
},
|
|
||||||
],
|
|
||||||
])
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
import { config, shallowMount } from '@vue/test-utils'
|
import { config, mount } from '@vue/test-utils'
|
||||||
import PostSlug from './index.vue'
|
import PostSlug from './index.vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import CommentList from '~/components/CommentList/CommentList'
|
import Vue from 'vue'
|
||||||
|
|
||||||
|
config.stubs['client-only'] = '<span><slot /></span>'
|
||||||
|
config.stubs['nuxt-link'] = '<span><slot /></span>'
|
||||||
|
config.stubs['router-link'] = '<span><slot /></span>'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
@ -16,8 +20,9 @@ describe('PostSlug', () => {
|
|||||||
store = new Vuex.Store({
|
store = new Vuex.Store({
|
||||||
getters: {
|
getters: {
|
||||||
'auth/user': () => {
|
'auth/user': () => {
|
||||||
return {}
|
return { id: '1stUser' }
|
||||||
},
|
},
|
||||||
|
'auth/isModerator': () => false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
propsData = {}
|
propsData = {}
|
||||||
@ -25,6 +30,7 @@ describe('PostSlug', () => {
|
|||||||
$t: jest.fn(),
|
$t: jest.fn(),
|
||||||
$filters: {
|
$filters: {
|
||||||
truncate: a => a,
|
truncate: a => a,
|
||||||
|
removeHtml: a => a,
|
||||||
},
|
},
|
||||||
$route: {
|
$route: {
|
||||||
hash: '',
|
hash: '',
|
||||||
@ -41,14 +47,15 @@ describe('PostSlug', () => {
|
|||||||
},
|
},
|
||||||
$apollo: {
|
$apollo: {
|
||||||
mutate: jest.fn().mockResolvedValue(),
|
mutate: jest.fn().mockResolvedValue(),
|
||||||
|
query: jest.fn().mockResolvedValue(),
|
||||||
},
|
},
|
||||||
|
$scrollTo: jest.fn(),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('mount', () => {
|
||||||
describe('shallowMount', () => {
|
|
||||||
Wrapper = () => {
|
Wrapper = () => {
|
||||||
return shallowMount(PostSlug, {
|
return mount(PostSlug, {
|
||||||
store,
|
store,
|
||||||
mocks,
|
mocks,
|
||||||
localVue,
|
localVue,
|
||||||
@ -56,20 +63,18 @@ describe('PostSlug', () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
beforeEach(jest.useFakeTimers)
|
|
||||||
|
|
||||||
describe('test Post callbacks', () => {
|
describe('test Post callbacks', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
wrapper.setData({
|
// wrapper.setData({
|
||||||
post: {
|
// post: {
|
||||||
id: 'p23',
|
// id: 'p23',
|
||||||
name: 'It is a post',
|
// name: 'It is a post',
|
||||||
author: {
|
// author: {
|
||||||
id: 'u1',
|
// id: 'u1',
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
})
|
// })
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('deletion of Post from Page by invoking "deletePostCallback()"', () => {
|
describe('deletion of Post from Page by invoking "deletePostCallback()"', () => {
|
||||||
@ -94,17 +99,38 @@ describe('PostSlug', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
describe('given a comment', () => {
|
describe('test Post callbacks', () => {
|
||||||
wrapper = Wrapper()
|
beforeEach(() => {
|
||||||
const bar = wrapper.find(CommentList)
|
beforeEach(jest.useFakeTimers)
|
||||||
it('hc-comment-list', () => {
|
wrapper = Wrapper()
|
||||||
expect(bar).toBe({"selector": "Component"})
|
})
|
||||||
|
it('CommentList', () => {
|
||||||
|
wrapper.setData({
|
||||||
|
post: {
|
||||||
|
id: 1,
|
||||||
|
author: {
|
||||||
|
id: '1stUser',
|
||||||
|
},
|
||||||
|
comments: [
|
||||||
|
{
|
||||||
|
id: 'comment134',
|
||||||
|
contentExcerpt: 'this is a comment',
|
||||||
|
content: 'this is a comment',
|
||||||
|
author: {
|
||||||
|
id: '1stUser',
|
||||||
|
slug: '1st-user',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
jest.runAllTimers()
|
||||||
|
Vue.nextTick()
|
||||||
|
const spy = jest.spyOn(wrapper.vm, 'reply')
|
||||||
|
console.log(spy)
|
||||||
|
expect(spy).toBe(true)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -72,10 +72,11 @@
|
|||||||
<!-- Comments -->
|
<!-- Comments -->
|
||||||
<ds-section slot="footer">
|
<ds-section slot="footer">
|
||||||
<hc-comment-list
|
<hc-comment-list
|
||||||
@reply="reply"
|
class="hc-comment-list-for-test"
|
||||||
:post="post"
|
:post="post"
|
||||||
:routeHash="$route.hash"
|
:routeHash="$route.hash"
|
||||||
@toggleNewCommentForm="toggleNewCommentForm"
|
@toggleNewCommentForm="toggleNewCommentForm"
|
||||||
|
@reply="reply"
|
||||||
/>
|
/>
|
||||||
<ds-space margin-bottom="large" />
|
<ds-space margin-bottom="large" />
|
||||||
<hc-comment-form
|
<hc-comment-form
|
||||||
@ -128,17 +129,11 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
post: null,
|
post: null,
|
||||||
ready: false,
|
ready: true,
|
||||||
title: 'loading',
|
title: 'loading',
|
||||||
showNewCommentForm: true,
|
showNewCommentForm: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
Post(post) {
|
|
||||||
this.post = post[0] || {}
|
|
||||||
this.title = this.post.title
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
mounted() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// NOTE: quick fix for jumping flexbox implementation
|
// NOTE: quick fix for jumping flexbox implementation
|
||||||
@ -210,6 +205,10 @@ export default {
|
|||||||
id: this.$route.params.id,
|
id: this.$route.params.id,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
update({ Post }) {
|
||||||
|
this.post = Post
|
||||||
|
this.title = this.post.title
|
||||||
|
},
|
||||||
fetchPolicy: 'cache-and-network',
|
fetchPolicy: 'cache-and-network',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user