diff options
Diffstat (limited to 'spec/frontend/vue_shared')
6 files changed, 59 insertions, 29 deletions
diff --git a/spec/frontend/vue_shared/components/expand_button_spec.js b/spec/frontend/vue_shared/components/expand_button_spec.js index a501e6695d5..e0893d02843 100644 --- a/spec/frontend/vue_shared/components/expand_button_spec.js +++ b/spec/frontend/vue_shared/components/expand_button_spec.js @@ -136,7 +136,10 @@ describe('Expand button', () => { it('clicking hides itself and shows prepend', () => { expect(expanderAppendEl().isVisible()).toBe(true); expanderAppendEl().trigger('click'); - expect(expanderPrependEl().isVisible()).toBe(true); + + return wrapper.vm.$nextTick().then(() => { + expect(expanderPrependEl().isVisible()).toBe(true); + }); }); it('clicking hides expanded text', () => { @@ -147,12 +150,15 @@ describe('Expand button', () => { .trim(), ).toBe(text.expanded); expanderAppendEl().trigger('click'); - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).not.toBe(text.expanded); + + return wrapper.vm.$nextTick().then(() => { + expect( + wrapper + .find(ExpandButton) + .text() + .trim(), + ).not.toBe(text.expanded); + }); }); describe('when short text is provided', () => { @@ -176,12 +182,15 @@ describe('Expand button', () => { .trim(), ).toBe(text.expanded); expanderAppendEl().trigger('click'); - expect( - wrapper - .find(ExpandButton) - .text() - .trim(), - ).toBe(text.short); + + return wrapper.vm.$nextTick().then(() => { + expect( + wrapper + .find(ExpandButton) + .text() + .trim(), + ).toBe(text.short); + }); }); }); }); diff --git a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js index 3cc640cb00d..21d05471d51 100644 --- a/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js +++ b/spec/frontend/vue_shared/components/issue/related_issuable_item_spec.js @@ -192,10 +192,12 @@ describe('RelatedIssuableItem', () => { it('triggers onRemoveRequest when clicked', () => { removeBtn.trigger('click'); - const { relatedIssueRemoveRequest } = wrapper.emitted(); + return wrapper.vm.$nextTick().then(() => { + const { relatedIssueRemoveRequest } = wrapper.emitted(); - expect(relatedIssueRemoveRequest.length).toBe(1); - expect(relatedIssueRemoveRequest[0]).toEqual([props.idKey]); + expect(relatedIssueRemoveRequest.length).toBe(1); + expect(relatedIssueRemoveRequest[0]).toEqual([props.idKey]); + }); }); }); }); diff --git a/spec/frontend/vue_shared/components/loading_button_spec.js b/spec/frontend/vue_shared/components/loading_button_spec.js index 34fac37c250..8bcb80d140e 100644 --- a/spec/frontend/vue_shared/components/loading_button_spec.js +++ b/spec/frontend/vue_shared/components/loading_button_spec.js @@ -80,7 +80,9 @@ describe('LoadingButton', () => { wrapper.trigger('click'); - expect(wrapper.emitted('click')).toBeTruthy(); + return wrapper.vm.$nextTick().then(() => { + expect(wrapper.emitted('click')).toBeTruthy(); + }); }); it('does not call given callback when disabled because of loading', () => { @@ -90,7 +92,9 @@ describe('LoadingButton', () => { wrapper.trigger('click'); - expect(wrapper.emitted('click')).toBeFalsy(); + return wrapper.vm.$nextTick().then(() => { + expect(wrapper.emitted('click')).toBeFalsy(); + }); }); }); }); diff --git a/spec/frontend/vue_shared/components/markdown/header_spec.js b/spec/frontend/vue_shared/components/markdown/header_spec.js index 1014fbf0308..3dfd4cfc942 100644 --- a/spec/frontend/vue_shared/components/markdown/header_spec.js +++ b/spec/frontend/vue_shared/components/markdown/header_spec.js @@ -66,11 +66,17 @@ describe('Markdown field header component', () => { it('emits toggle markdown event when clicking preview', () => { wrapper.find('.js-preview-link').trigger('click'); - expect(wrapper.emitted('preview-markdown').length).toEqual(1); - - wrapper.find('.js-write-link').trigger('click'); - - expect(wrapper.emitted('write-markdown').length).toEqual(1); + return wrapper.vm + .$nextTick() + .then(() => { + expect(wrapper.emitted('preview-markdown').length).toEqual(1); + + wrapper.find('.js-write-link').trigger('click'); + return wrapper.vm.$nextTick(); + }) + .then(() => { + expect(wrapper.emitted('write-markdown').length).toEqual(1); + }); }); it('does not emit toggle markdown event when triggered from another form', () => { diff --git a/spec/frontend/vue_shared/components/modal_copy_button_spec.js b/spec/frontend/vue_shared/components/modal_copy_button_spec.js index 3c71cb16bd5..a57655dd580 100644 --- a/spec/frontend/vue_shared/components/modal_copy_button_spec.js +++ b/spec/frontend/vue_shared/components/modal_copy_button_spec.js @@ -29,14 +29,20 @@ describe('modal copy button', () => { removeAllRanges: jest.fn(), })); wrapper.trigger('click'); - expect(wrapper.emitted().success).not.toBeEmpty(); - expect(document.execCommand).toHaveBeenCalledWith('copy'); + + return wrapper.vm.$nextTick().then(() => { + expect(wrapper.emitted().success).not.toBeEmpty(); + expect(document.execCommand).toHaveBeenCalledWith('copy'); + }); }); it("should propagate the clipboard error event if execCommand doesn't work", () => { document.execCommand = jest.fn(() => false); wrapper.trigger('click'); - expect(wrapper.emitted().error).not.toBeEmpty(); - expect(document.execCommand).toHaveBeenCalledWith('copy'); + + return wrapper.vm.$nextTick().then(() => { + expect(wrapper.emitted().error).not.toBeEmpty(); + expect(document.execCommand).toHaveBeenCalledWith('copy'); + }); }); }); }); diff --git a/spec/frontend/vue_shared/directives/track_event_spec.js b/spec/frontend/vue_shared/directives/track_event_spec.js index d63f6ae05b4..c9b0520ab2c 100644 --- a/spec/frontend/vue_shared/directives/track_event_spec.js +++ b/spec/frontend/vue_shared/directives/track_event_spec.js @@ -43,7 +43,10 @@ describe('Error Tracking directive', () => { wrapper.setData({ trackingOptions }); const { category, action, label, property, value } = trackingOptions; - button.trigger('click'); - expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property, value }); + + return wrapper.vm.$nextTick(() => { + button.trigger('click'); + expect(Tracking.event).toHaveBeenCalledWith(category, action, { label, property, value }); + }); }); }); |