test save categories

This commit is contained in:
Moriz Wahl 2022-09-06 19:17:06 +02:00
parent dcdef615c1
commit 3213bd3ee4

View File

@ -15,8 +15,19 @@ describe('CategoriesFilter.vue', () => {
'posts/filteredCategoryIds': jest.fn(() => []),
}
const apolloMutationMock = jest.fn().mockResolvedValue({
data: { saveCategorySettings: true },
})
const mocks = {
$t: jest.fn((string) => string),
$apollo: {
mutate: apolloMutationMock,
},
$toast: {
success: jest.fn(),
error: jest.fn(),
},
}
const Wrapper = () => {
@ -76,5 +87,14 @@ describe('CategoriesFilter.vue', () => {
expect(mutations['posts/RESET_CATEGORIES']).toHaveBeenCalledTimes(1)
})
})
describe('save categories', () => {
it('calls the API', async () => {
wrapper = await Wrapper()
const saveButton = wrapper.findAll('.categories-filter .sidebar .base-button').at(1)
saveButton.trigger('click')
expect(apolloMutationMock).toBeCalled()
})
})
})
})