mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Test clicks on the emotions buttons
- Add tests for clicks on the emotion button - Refactor name of TOGGLE_EMOTIONS
This commit is contained in:
parent
11dd61c430
commit
9a6a3a6bea
@ -19,6 +19,7 @@ describe('FilterPosts.vue', () => {
|
||||
let allCategoriesButton
|
||||
let environmentAndNatureButton
|
||||
let democracyAndPoliticsButton
|
||||
let happyEmotionButton
|
||||
|
||||
beforeEach(() => {
|
||||
mocks = {
|
||||
@ -52,6 +53,7 @@ describe('FilterPosts.vue', () => {
|
||||
'postsFilter/TOGGLE_FILTER_BY_FOLLOWED': jest.fn(),
|
||||
'postsFilter/RESET_CATEGORIES': jest.fn(),
|
||||
'postsFilter/TOGGLE_CATEGORY': jest.fn(),
|
||||
'postsFilter/TOGGLE_EMOTION': jest.fn(),
|
||||
}
|
||||
getters = {
|
||||
'postsFilter/isActive': () => false,
|
||||
@ -121,5 +123,22 @@ describe('FilterPosts.vue', () => {
|
||||
expect(mutations['postsFilter/TOGGLE_FILTER_BY_FOLLOWED']).toHaveBeenCalledWith({}, 'u34')
|
||||
})
|
||||
})
|
||||
|
||||
describe('click on an "emotions-buttons" button', () => {
|
||||
it('calls TOGGLE_EMOTION when clicked', () => {
|
||||
const wrapper = openFilterPosts()
|
||||
happyEmotionButton = wrapper.findAll('button.emotions-buttons').at(1)
|
||||
happyEmotionButton.trigger('click')
|
||||
expect(mutations['postsFilter/TOGGLE_EMOTION']).toHaveBeenCalledWith({}, 'happy')
|
||||
})
|
||||
|
||||
it('sets the attribute `src` to colorized image', () => {
|
||||
getters['postsFilter/filteredByEmotions'] = jest.fn(() => ['happy'])
|
||||
const wrapper = openFilterPosts()
|
||||
happyEmotionButton = wrapper.findAll('button.emotions-buttons').at(1)
|
||||
const happyEmotionButtonImage = happyEmotionButton.find('img')
|
||||
expect(happyEmotionButtonImage.attributes().src).toEqual('/img/svg/emoji/happy_color.svg')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -72,7 +72,7 @@ export default {
|
||||
methods: {
|
||||
...mapMutations({
|
||||
toggleFilteredByFollowed: 'postsFilter/TOGGLE_FILTER_BY_FOLLOWED',
|
||||
toogleFilteredByEmotions: 'postsFilter/TOGGLE_FILTER_BY_EMOTIONS',
|
||||
toogleFilteredByEmotions: 'postsFilter/TOGGLE_EMOTION',
|
||||
}),
|
||||
iconPath(emotion) {
|
||||
if (this.filteredByEmotions.includes(emotion)) {
|
||||
|
||||
@ -40,7 +40,7 @@ export const mutations = {
|
||||
if (isEmpty(get(filter, 'categories_some.id_in'))) delete filter.categories_some
|
||||
state.filter = filter
|
||||
},
|
||||
TOGGLE_FILTER_BY_EMOTIONS(state, emotion) {
|
||||
TOGGLE_EMOTION(state, emotion) {
|
||||
const filter = clone(state.filter)
|
||||
update(filter, 'emotions_some.emotion_in', emotions => xor(emotions, [emotion]))
|
||||
if (isEmpty(get(filter, 'emotions_some.emotion_in'))) delete filter.emotions_some
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user