diff options
author | Scott Hampton <shampton@gitlab.com> | 2019-06-05 14:51:07 -0700 |
---|---|---|
committer | Scott Hampton <shampton@gitlab.com> | 2019-06-05 14:51:07 -0700 |
commit | 745b6dbad5d4f4fff9b7fc6a5d654c9f2d458df7 (patch) | |
tree | 938041e283ce678b5c5a1eafb1eac3851fb88875 | |
parent | f0c255487e4786c7410a1c1b0366c6eff332b1b8 (diff) | |
download | gitlab-ce-copy-button-in-modals.tar.gz |
Fixing a tooltip spec issuecopy-button-in-modals
Apparently jest has a hard time with tooltips,
so the test was pulling it up as undefined.
I have added a check in the method to make
sure that tooltip is defined before proceeding.
-rw-r--r-- | app/assets/javascripts/vue_shared/components/modal_copy_button.vue | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/app/assets/javascripts/vue_shared/components/modal_copy_button.vue b/app/assets/javascripts/vue_shared/components/modal_copy_button.vue index 0d922539ea0..bf59a6abf3f 100644 --- a/app/assets/javascripts/vue_shared/components/modal_copy_button.vue +++ b/app/assets/javascripts/vue_shared/components/modal_copy_button.vue @@ -91,17 +91,18 @@ export default { const $target = $(target); const originalTitle = $target.data('originalTitle'); - /** - * The original tooltip will continue staying there unless we remove it by hand. - * $target.tooltip('hide') isn't working. - */ - $('.tooltip').remove(); - $target - .attr('title', this.$options.copySuccessText) - .tooltip('_fixTitle') - .tooltip('show') - .attr('title', originalTitle) - .tooltip('_fixTitle'); + if ($target.tooltip) { + /** + * The original tooltip will continue staying there unless we remove it by hand. + * $target.tooltip('hide') isn't working. + */ + $('.tooltip').remove(); + $target.attr('title', this.$options.copySuccessText); + $target.tooltip('_fixTitle'); + $target.tooltip('show'); + $target.attr('title', originalTitle); + $target.tooltip('_fixTitle'); + } }, }, }; |