jenkins-bot has submitted this change and it was merged.

Change subject: Add QUnit tests to cover ext.popups.core.js
......................................................................


Add QUnit tests to cover ext.popups.core.js

Bug: T133020
Depends-On: Icb1e6ddc8f95da5e4b4de2916d292694c11ba731
Change-Id: Id173b215701abb87f998722526d643f36f3c0308
---
M tests/qunit/ext.popups.core.test.js
1 file changed, 89 insertions(+), 0 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, but someone else must approve
  Phuedx: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/qunit/ext.popups.core.test.js 
b/tests/qunit/ext.popups.core.test.js
index a006e7b..ca630ea 100644
--- a/tests/qunit/ext.popups.core.test.js
+++ b/tests/qunit/ext.popups.core.test.js
@@ -33,4 +33,93 @@
                }
        } );
 
+       QUnit.test( 'removeTooltips', function ( assert ) {
+               var $link = $( '<a>', {
+                       text: 'link with tooltip',
+                       title: 'link title',
+                       href: '#'  // `href` is needed for testing the `focus` 
event
+               } ).appendTo( 'body' );
+
+               QUnit.expect( 5 );
+
+               mw.popups.removeTooltips( $link );
+
+               $link.trigger( 'mouseenter' );
+               assert.equal( $link.attr( 'title' ), '', 'The link does not 
have a title on mouseenter.' );
+
+               $link.trigger( 'mouseleave' );
+               assert.equal( $link.attr( 'title' ), 'link title', 'The link 
has a title on mouseleave.' );
+
+               $link.trigger( 'focus' );
+               assert.equal( $link.attr( 'title' ), '', 'The link does not 
have a title on focus.' );
+
+               $link.trigger( 'blur' );
+               assert.equal( $link.attr( 'title' ), 'link title', 'The link 
has a title on blur.' );
+
+               $link.data( 'dont-empty-title', true );
+               $link.trigger( 'mouseenter' );
+               assert.equal( $link.attr( 'title' ), 'link title',
+                       'The link title is not removed when `dont-empty-title` 
data attribute is `true`.' );
+
+               $link.remove();
+       } );
+
+       QUnit.test( 'selectPopupElements', function ( assert ) {
+               var $originalContent = mw.popups.$content,
+                       IGNORE_CLASSES = [
+                               '.extiw',
+                               '.image',
+                               '.new',
+                               '.internal',
+                               '.external',
+                               '.oo-ui-buttonedElement-button'
+                       ],
+                       $cancelLink = $( '<span>', {
+                               class: 'cancelLink'
+                       } );
+
+               QUnit.expect( 1 );
+
+               mw.popups.$content = $( '<div>' );
+
+               // add links that we know will be ignored
+               $.each( IGNORE_CLASSES, function ( i, className ) {
+                       $( '<a>', {
+                               text: 'link with tooltip',
+                               title: 'link title',
+                               class: className.substring( 1 ),
+                               href: '/wiki/Popups'
+                       } ).appendTo( mw.popups.$content );
+               } );
+
+               // add a link that's part of a .cancelLink
+               $( '<a>', {
+                       text: 'link with tooltip',
+                       title: 'link title',
+                       href: '/wiki/Popups'
+               } ).appendTo( $cancelLink );
+               $cancelLink.appendTo( mw.popups.$content );
+
+               // add a link without `href`, which means the link doesn't 
point to a valid page
+               $( '<a>', {
+                       text: 'link with tooltip',
+                       title: 'link title'
+               } ).appendTo( mw.popups.$content );
+
+               // add a link that will have a hover card
+               $( '<a>', {
+                       text: 'link with tooltip',
+                       title: 'link title',
+                       href: '/wiki/Popups'
+               } ).appendTo( mw.popups.$content );
+
+               // only the last link above should be selected for having a 
hover card
+               assert.equal(
+                       mw.popups.selectPopupElements().length,
+                       1,
+                       'Explicitly ignored links and links that do not have a 
`href` attribute are not considered for having a popup.' );
+
+               mw.popups.$content = $originalContent;
+       } );
+
 } )( jQuery, mediaWiki );

-- 
To view, visit https://gerrit.wikimedia.org/r/283348
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id173b215701abb87f998722526d643f36f3c0308
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Bmansurov <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to