mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
* After creating the post, the author of it automatically observes it to get notifications when there are interactions * a user that comments a post, automatically observes that post to get notifications when there are more interactions on that post * mutation that switches the state of the obeservation of a post on and off * remove duplicate code * fix unit tests * add metric observed users count to posts * change naming * Add follow post entry to post menu * Add FollowButton (WIP), show unfollow in menu when already followed * Follow/unfollow post => observe * Update slashed bell * Add requests to observe/unobserve posts * Add ObserveButton functionality * Rename isObservedByMe * Add observingUsersCount; simplify ObserveButton and menu entries * Fix locales * Add snapshot test for ObserveButton (WIP) * Remove empty routes push * Add test for ObserveButton * Add test for ContentMenu, improve ObserveButton test * Remove unneeded fields from PostQuery --------- Co-authored-by: Moriz Wahl <moriz.wahl@gmx.de>
61 lines
1.3 KiB
JavaScript
61 lines
1.3 KiB
JavaScript
import { mount } from '@vue/test-utils'
|
|
import ObserveButton from './ObserveButton.vue'
|
|
|
|
const localVue = global.localVue
|
|
|
|
describe('ObserveButton', () => {
|
|
let mocks
|
|
|
|
const Wrapper = (count = 1, postId = '123', isObserved = true) => {
|
|
return mount(ObserveButton, {
|
|
mocks,
|
|
localVue,
|
|
propsData: {
|
|
count,
|
|
postId,
|
|
isObserved,
|
|
},
|
|
})
|
|
}
|
|
|
|
let wrapper
|
|
|
|
beforeEach(() => {
|
|
mocks = {
|
|
$t: jest.fn(),
|
|
}
|
|
})
|
|
|
|
describe('observed', () => {
|
|
beforeEach(() => {
|
|
wrapper = Wrapper(1, '123', true)
|
|
})
|
|
|
|
it('renders', () => {
|
|
expect(wrapper.element).toMatchSnapshot()
|
|
})
|
|
|
|
it('emits toggleObservePost with false when clicked', () => {
|
|
const button = wrapper.find('.base-button')
|
|
button.trigger('click')
|
|
expect(wrapper.emitted('toggleObservePost')).toEqual([['123', false]])
|
|
})
|
|
})
|
|
|
|
describe('unobserved', () => {
|
|
beforeEach(() => {
|
|
wrapper = Wrapper(1, '123', false)
|
|
})
|
|
|
|
it('renders', () => {
|
|
expect(wrapper.element).toMatchSnapshot()
|
|
})
|
|
|
|
it('emits toggleObservePost with true when clicked', () => {
|
|
const button = wrapper.find('.base-button')
|
|
button.trigger('click')
|
|
expect(wrapper.emitted('toggleObservePost')).toEqual([['123', true]])
|
|
})
|
|
})
|
|
})
|