From cdc9cd0af22b9701ead8135f74205965c221f978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Sun, 10 Mar 2019 00:48:35 +0100 Subject: [PATCH] Await async mehtods in ReportModal.spec.js --- components/ReportModal.spec.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/components/ReportModal.spec.js b/components/ReportModal.spec.js index a64424ea8..d138ea61e 100644 --- a/components/ReportModal.spec.js +++ b/components/ReportModal.spec.js @@ -66,25 +66,33 @@ describe('ReportModal.vue', () => { }) describe('click confirm button', () => { - const clickAction = () => { + const clickAction = async () => { const confirmButton = wrapper.find('.ds-button-danger') - confirmButton.trigger('click') + await confirmButton.trigger('click') } - it('calls report mutation', () => { - clickAction() + it('calls report mutation', async () => { + await clickAction() expect($apollo.mutate).toHaveBeenCalled() }) - it.todo('hides modal') + it('hides modal', async () => { + expect(wrapper.find('.ds-modal-wrapper').isEmpty()).toEqual(false) + await clickAction() + expect(wrapper.find('.ds-modal-wrapper').isEmpty()).toEqual(true) + }) - it('disables buttons', () => { + it('disables buttons', async () => { const expected = { disabled: 'disabled' } let cancelButton = wrapper.findAll('footer button').at(0) let confirmButton = wrapper.findAll('footer button').at(1) - expect(cancelButton.attributes().disabled).toBeUndefined() - expect(confirmButton.attributes().disabled).toBeUndefined() - clickAction() + expect(cancelButton.attributes()).toEqual( + expect.not.objectContaining(expected) + ) + expect(confirmButton.attributes()).toEqual( + expect.not.objectContaining(expected) + ) + await clickAction() expect(cancelButton.attributes()).toEqual( expect.objectContaining(expected) )