diff options
Diffstat (limited to 'spec/frontend/tooltips')
-rw-r--r-- | spec/frontend/tooltips/components/tooltips_spec.js | 8 | ||||
-rw-r--r-- | spec/frontend/tooltips/index_spec.js | 29 |
2 files changed, 35 insertions, 2 deletions
diff --git a/spec/frontend/tooltips/components/tooltips_spec.js b/spec/frontend/tooltips/components/tooltips_spec.js index 0edc5248629..50848ca2978 100644 --- a/spec/frontend/tooltips/components/tooltips_spec.js +++ b/spec/frontend/tooltips/components/tooltips_spec.js @@ -80,6 +80,14 @@ describe('tooltips/components/tooltips.vue', () => { expect(wrapper.find(GlTooltip).html()).toContain(target.getAttribute('title')); }); + it('sets the configuration values passed in the config object', async () => { + const config = { show: true }; + target = createTooltipTarget(); + wrapper.vm.addTooltips([target], config); + await wrapper.vm.$nextTick(); + expect(wrapper.find(GlTooltip).props()).toMatchObject(config); + }); + it.each` attribute | value | prop ${'data-placement'} | ${'bottom'} | ${'placement'} diff --git a/spec/frontend/tooltips/index_spec.js b/spec/frontend/tooltips/index_spec.js index cc72adee57d..511003fdb8f 100644 --- a/spec/frontend/tooltips/index_spec.js +++ b/spec/frontend/tooltips/index_spec.js @@ -1,5 +1,15 @@ import jQuery from 'jquery'; -import { initTooltips, dispose, destroy, hide, show, enable, disable, fixTitle } from '~/tooltips'; +import { + add, + initTooltips, + dispose, + destroy, + hide, + show, + enable, + disable, + fixTitle, +} from '~/tooltips'; describe('tooltips/index.js', () => { let tooltipsApp; @@ -67,6 +77,20 @@ describe('tooltips/index.js', () => { }); }); + describe('add', () => { + it('adds a GlTooltip for the specified elements', async () => { + const target = createTooltipTarget(); + + buildTooltipsApp(); + add([target], { title: 'custom title' }); + + await tooltipsApp.$nextTick(); + + expect(document.querySelector('.gl-tooltip')).not.toBe(null); + expect(document.querySelector('.gl-tooltip').innerHTML).toContain('custom title'); + }); + }); + describe('dispose', () => { it('removes tooltips that target the elements specified', async () => { const target = createTooltipTarget(); @@ -136,12 +160,13 @@ describe('tooltips/index.js', () => { ${disable} | ${'disable'} | ${'disable'} ${hide} | ${'hide'} | ${'hide'} ${show} | ${'show'} | ${'show'} + ${add} | ${'init'} | ${{ title: 'the title' }} `('delegates $methodName to bootstrap tooltip API', ({ method, bootstrapParams }) => { const elements = jQuery(createTooltipTarget()); jest.spyOn(jQuery.fn, 'tooltip'); - method(elements); + method(elements, bootstrapParams); expect(elements.tooltip).toHaveBeenCalledWith(bootstrapParams); }); |