mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
56 lines
1.4 KiB
JavaScript
56 lines
1.4 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import SearchPost from './SearchPost.vue'
|
|
|
|
const localVue = global.localVue
|
|
localVue.filter('dateTime', (d) => d)
|
|
|
|
describe('SearchPost.vue', () => {
|
|
let mocks, wrapper, propsData, counts
|
|
beforeEach(() => {
|
|
mocks = {
|
|
$t: jest.fn((string) => string),
|
|
}
|
|
propsData = {
|
|
option: {
|
|
title: 'Post Title',
|
|
commentsCount: 3,
|
|
shoutedCount: 6,
|
|
clickedCount: 5,
|
|
viewedTeaserCount: 15,
|
|
createdAt: '23.08.2019',
|
|
author: {
|
|
name: 'Post Author',
|
|
},
|
|
},
|
|
}
|
|
wrapper = Wrapper()
|
|
counts = wrapper.find('.search-post > .metadata > .counts')
|
|
})
|
|
|
|
const Wrapper = () => {
|
|
return mount(SearchPost, { mocks, localVue, propsData })
|
|
}
|
|
|
|
describe('shallowMount', () => {
|
|
it('renders post title', () => {
|
|
expect(wrapper.find('.search-post > .label').text()).toMatch('Post Title')
|
|
})
|
|
|
|
it('renders post commentsCount', () => {
|
|
expect(counts.text()).toContain(propsData.option.commentsCount.toString())
|
|
})
|
|
|
|
it('renders post shoutedCount', () => {
|
|
expect(counts.text()).toContain(propsData.option.shoutedCount.toString())
|
|
})
|
|
|
|
it('renders post author', () => {
|
|
expect(wrapper.find('.search-post > .metadata').text()).toContain('Post Author')
|
|
})
|
|
|
|
it('renders post createdAt', () => {
|
|
expect(wrapper.find('.search-post > .metadata').text()).toContain('23.08.2019')
|
|
})
|
|
})
|
|
})
|