Merge branch '4265-move-sort-newsfeed-menu-into-filter-menu-moriz' of github.com:Ocelot-Social-Community/Ocelot-Social into 4265-move-sort-newsfeed-menu-into-filter-menu

# Conflicts:
#	webapp/components/DonationInfo/DonationInfo.spec.js
#	webapp/pages/admin/donations.spec.js
This commit is contained in:
Wolfgang Huß 2021-09-15 13:53:10 +02:00
commit 8251877bd9
2 changed files with 43 additions and 28 deletions

View File

@ -48,7 +48,6 @@ describe('DonationInfo.vue', () => {
describe('given german locale', () => {
beforeEach(() => {
mocks.$i18n.locale = () => 'de'
wrapper = Wrapper()
})
// it looks to me that toLocaleString for some reason is not working as expected

View File

@ -8,24 +8,38 @@ describe('donations.vue', () => {
let wrapper
let mocks
const donationsQueryMock = jest.fn()
const donationsUpdateMock = jest.fn()
const donationsMutaionMock = jest.fn()
donationsMutaionMock.mockResolvedValue({
then: jest.fn(),
catch: jest.fn(),
})
beforeEach(() => {
mocks = {
$t: jest.fn((string) => string),
$apollo: {
// queries: {
// Donations: {
// refetch: jest.fn(),
// // fetchMore: jest.fn().mockResolvedValue([
// // {
// // id: 'p23',
// // name: 'It is a post',
// // author: {
// // id: 'u1',
// // },
// // },
// // ]),
// },
// },
Donations: {
query: donationsQueryMock,
update: donationsUpdateMock,
},
mutate: donationsMutaionMock,
queries: {
Donations: {
query: donationsQueryMock,
refetch: jest.fn(),
fetchMore: jest.fn().mockResolvedValue([
{
id: 'p23',
name: 'It is a post',
author: {
id: 'u1',
},
},
]),
},
},
// query: jest.fn().mockResolvedValue({
// data: {
// Donations: 1,
@ -100,17 +114,18 @@ describe('donations.vue', () => {
})
it.skip('on donations-goal and enter value XXX', async () => {
wrapper.find('#showDonations').trigger('click') // set to true
// wrapper.find('[data-test="donations-goal"]').setValue('20000')
wrapper.find('#donations-goal').setValue('20000')
await wrapper.vm.$nextTick()
console.log(wrapper.find('#donations-goal').element.value)
expect(wrapper.vm.formData.goal).toBe('20000')
})
})
describe('apollo', () => {
it.skip('query is called', () => {
// expect(mocks.$apollo.queries.Donations.refetch).toHaveBeenCalledTimes(1)
expect(donationsQueryMock).toHaveBeenCalledTimes(1)
expect(mocks.$apollo.queries.Donations.refetch).toHaveBeenCalledTimes(1)
// expect(mocks.$apollo.Donations.query().exists()).toBeTruthy()
console.log('mocks.$apollo: ', mocks.$apollo)
})
@ -124,35 +139,36 @@ describe('donations.vue', () => {
})
describe('submit', () => {
it.skip('calls mutation with default values once', async () => {
beforeEach(() => {
jest.clearAllMocks()
})
it('calls mutation with default values once', () => {
// TODO: Makes the warning: "UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'error' of undefined"
wrapper.find('.donations-info-button').trigger('submit')
await mocks.$apollo.mutate
// await flushPromises()
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(
//await flushPromises()
expect(donationsMutaionMock).toHaveBeenCalledWith(
expect.objectContaining({
variables: { showDonations: false, goal: 15000, progress: 0 },
}),
)
expect(mocks.$apollo.mutate).toHaveBeenCalledTimes(1)
})
it.skip('calls mutation with input values once', async () => {
it('calls mutation with input values once', async () => {
wrapper.find('#showDonations').trigger('click') // set to true
await wrapper.vm.$nextTick()
// wrapper.find('[data-test="donations-goal"]').setValue('20000')
//wrapper.find('[data-test="donations-goal"]').setValue('20000')
wrapper.find('#donations-goal').setValue('20000')
await wrapper.vm.$nextTick()
// expect(wrapper.vm.formData.goal).toBe('20000')
wrapper.find('.donations-info-button').trigger('submit')
await mocks.$apollo.mutate
await wrapper.vm.$nextTick()
//await mocks.$apollo.mutate
await flushPromises()
expect(mocks.$apollo.mutate).toHaveBeenCalledWith(
expect.objectContaining({
variables: { showDonations: true, goal: 15000, progress: 0 },
variables: { showDonations: true, goal: 20000, progress: 0 },
}),
)
expect(mocks.$apollo.mutate).toHaveBeenCalledTimes(1)
})
it.skip('calls mutation with corrected values once', async () => {