This commit is contained in:
ogerly 2022-10-28 13:15:44 +02:00
parent 9b7dc2cac7
commit c0bab3cd50
5 changed files with 13 additions and 13 deletions

View File

@ -59,20 +59,20 @@ describe('CategoriesFilter.vue', () => {
describe('mount', () => {
it('starts with all categories button active', () => {
const allCategoriesButton = wrapper.find('.categories-filter .sidebar .base-button')
const allCategoriesButton = wrapper.find('.categories-filter .item-all-themen .base-button')
expect(allCategoriesButton.attributes().class).toContain('--filled')
})
it('sets category button attribute `filled` when corresponding category is filtered', async () => {
getters['posts/filteredCategoryIds'] = jest.fn(() => ['cat9'])
wrapper = await Wrapper()
democracyAndPoliticsButton = wrapper.findAll('.categories-filter .item .base-button').at(2)
democracyAndPoliticsButton = wrapper.find('.categories-filter .item-save-themen .base-button')
expect(democracyAndPoliticsButton.attributes().class).toContain('--filled')
})
describe('click on an "catetories-buttons" button', () => {
it('calls TOGGLE_CATEGORY when clicked', () => {
environmentAndNatureButton = wrapper.findAll('.categories-filter .item .base-button').at(0)
environmentAndNatureButton = wrapper.findAll('.categories-filter .item-category .base-button').at(0)
environmentAndNatureButton.trigger('click')
expect(mutations['posts/TOGGLE_CATEGORY']).toHaveBeenCalledWith({}, 'cat4')
})
@ -82,7 +82,7 @@ describe('CategoriesFilter.vue', () => {
it('when all button is clicked', async () => {
getters['posts/filteredCategoryIds'] = jest.fn(() => ['cat9'])
wrapper = await Wrapper()
const allCategoriesButton = wrapper.find('.categories-filter .sidebar .base-button')
const allCategoriesButton = wrapper.find('.categories-filter .item-all-themen .base-button')
allCategoriesButton.trigger('click')
expect(mutations['posts/RESET_CATEGORIES']).toHaveBeenCalledTimes(1)
})
@ -91,7 +91,7 @@ describe('CategoriesFilter.vue', () => {
describe('save categories', () => {
it('calls the API', async () => {
wrapper = await Wrapper()
const saveButton = wrapper.findAll('.categories-filter .sidebar .base-button').at(1)
const saveButton = wrapper.find('.categories-filter .item-save-themen .base-button')
saveButton.trigger('click')
expect(apolloMutationMock).toBeCalled()
})

View File

@ -1,7 +1,7 @@
<template>
<filter-menu-section :title="$t('filter-menu.categories')" class="categories-filter">
<template #filter-themen>
<li class="item">
<li class="item item-all-themen">
<labeled-button
:filled="!filteredCategoryIds.length"
:label="$t('filter-menu.all')"
@ -9,13 +9,13 @@
@click="resetCategories"
/>
</li>
<li class="item">
<li class="item item-save-themen">
<labeled-button filled :label="$t('actions.save')" icon="save" @click="saveCategories" />
</li>
</template>
<template #filter-list>
<li v-for="category in categories" :key="category.id" class="item">
<li v-for="category in categories" :key="category.id" class="item item-category">
<labeled-button
:icon="category.icon"
:filled="filteredCategoryIds.includes(category.id)"

View File

@ -8,9 +8,9 @@
<ul class="filter-list">
<slot name="filter-themen" />
</ul>
<!-- <aside class="sidebar">
<aside class="sidebar">
<slot name="sidebar" />
</aside> -->
</aside>
<!-- <div v-if="divider" class="divider" /> -->
<ul class="filter-list">
<slot name="filter-list" />

View File

@ -35,12 +35,12 @@ describe('FollowingFilter', () => {
it('sets "filter-by-followed" button attribute `filled`', () => {
getters['posts/filteredByUsersFollowed'] = jest.fn(() => true)
const wrapper = Wrapper()
expect(wrapper.find('.following-filter .sidebar .base-button').classes('--filled')).toBe(true)
expect(wrapper.find('.following-filter .filter-list .follower-item .base-button').classes('--filled')).toBe(true)
})
describe('click "filter-by-followed" button', () => {
it('calls TOGGLE_FILTER_BY_FOLLOWED', () => {
wrapper.find('.following-filter .sidebar .base-button').trigger('click')
wrapper.find('.following-filter .filter-list .follower-item .base-button').trigger('click')
expect(mutations['posts/TOGGLE_FILTER_BY_FOLLOWED']).toHaveBeenCalledWith({}, 'u34')
})
})

View File

@ -1,7 +1,7 @@
<template>
<filter-menu-section :divider="false" class="following-filter">
<template #filter-follower>
<li class="item">
<li class="item follower-item">
<labeled-button
icon="user-plus"
:label="$t('filter-menu.following')"