Use of mutation enable removed, fix fronend tests

- The mutation definition still has to be removed.
This commit is contained in:
Wolfgang Huß 2019-11-06 14:34:24 +01:00
parent a4521b4621
commit d4e7e10f8c
3 changed files with 17 additions and 13 deletions

View File

@ -29,9 +29,7 @@ describe('DisableModal.vue', () => {
$apollo: { $apollo: {
mutate: jest mutate: jest
.fn() .fn()
.mockResolvedValueOnce({ .mockResolvedValueOnce()
enable: 'u4711',
})
.mockRejectedValue({ .mockRejectedValue({
message: 'Not Authorised!', message: 'Not Authorised!',
}), }),
@ -162,11 +160,13 @@ describe('DisableModal.vue', () => {
expect(mocks.$apollo.mutate).toHaveBeenCalled() expect(mocks.$apollo.mutate).toHaveBeenCalled()
}) })
it('passes id to mutation', () => { it('passes parameters to mutation', () => {
const calls = mocks.$apollo.mutate.mock.calls const calls = mocks.$apollo.mutate.mock.calls
const [[{ variables }]] = calls const [[{ variables }]] = calls
expect(variables).toEqual({ expect(variables).toMatchObject({
id: 'u4711', resourceId: 'u4711',
disable: true,
closed: false,
}) })
}) })

View File

@ -30,7 +30,7 @@ describe('ReleaseModal.vue', () => {
$apollo: { $apollo: {
mutate: jest mutate: jest
.fn() .fn()
.mockResolvedValueOnce({ enable: 'u4711' }) .mockResolvedValueOnce()
.mockRejectedValue({ message: 'Not Authorised!' }), .mockRejectedValue({ message: 'Not Authorised!' }),
}, },
location: { location: {
@ -157,11 +157,13 @@ describe('ReleaseModal.vue', () => {
expect(mocks.$apollo.mutate).toHaveBeenCalled() expect(mocks.$apollo.mutate).toHaveBeenCalled()
}) })
it('passes id to mutation', () => { it('passes parameters to mutation', () => {
const calls = mocks.$apollo.mutate.mock.calls const calls = mocks.$apollo.mutate.mock.calls
const [[{ variables }]] = calls const [[{ variables }]] = calls
expect(variables).toEqual({ expect(variables).toMatchObject({
id: 'u4711', resourceId: 'u4711',
disable: false,
closed: false,
}) })
}) })

View File

@ -53,11 +53,13 @@ export default {
// await this.modalData.buttons.confirm.callback() // await this.modalData.buttons.confirm.callback()
await this.$apollo.mutate({ await this.$apollo.mutate({
mutation: gql` mutation: gql`
mutation($id: ID!) { mutation($resourceId: ID!, $disable: Boolean, $closed: Boolean) {
enable(id: $id) decide(resourceId: $resourceId, disable: $disable, closed: $closed) {
disable
}
} }
`, `,
variables: { id: this.id }, variables: { resourceId: this.id, disable: false, closed: false },
}) })
this.$toast.success(this.$t('release.success')) this.$toast.success(this.$t('release.success'))
this.isOpen = false this.isOpen = false