summaryrefslogtreecommitdiff
path: root/spec/frontend/tooltips/index_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/tooltips/index_spec.js')
-rw-r--r--spec/frontend/tooltips/index_spec.js29
1 files changed, 27 insertions, 2 deletions
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);
});