2015-04-07 00:28:55 +00:00
|
|
|
define( [
|
2016-04-06 13:59:12 +00:00
|
|
|
"qunit",
|
2015-04-07 00:28:55 +00:00
|
|
|
"jquery",
|
2020-05-16 07:16:24 +00:00
|
|
|
"./helper",
|
2015-07-15 02:12:14 +00:00
|
|
|
"ui/widgets/tooltip"
|
2020-05-16 07:16:24 +00:00
|
|
|
], function( QUnit, $, testHelper ) {
|
2021-06-06 22:58:12 +00:00
|
|
|
"use strict";
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2020-05-16 07:16:24 +00:00
|
|
|
var beforeAfterEach = testHelper.beforeAfterEach;
|
|
|
|
|
|
|
|
QUnit.module( "tooltip: events", beforeAfterEach() );
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2016-04-06 13:59:12 +00:00
|
|
|
QUnit.test( "programmatic triggers", function( assert ) {
|
|
|
|
assert.expect( 4 );
|
2011-05-30 22:51:29 +00:00
|
|
|
var tooltip,
|
|
|
|
element = $( "#tooltipped1" ).tooltip();
|
2011-05-28 20:20:46 +00:00
|
|
|
|
2011-05-30 22:51:29 +00:00
|
|
|
element.one( "tooltipopen", function( event, ui ) {
|
|
|
|
tooltip = ui.tooltip;
|
2016-04-06 13:59:12 +00:00
|
|
|
assert.ok( !( "originalEvent" in event ), "open" );
|
|
|
|
assert.strictEqual( ui.tooltip[ 0 ],
|
2015-08-24 12:50:46 +00:00
|
|
|
$( "#" + element.data( "ui-tooltip-id" ) )[ 0 ], "ui.tooltip" );
|
|
|
|
} );
|
2011-05-28 20:20:46 +00:00
|
|
|
element.tooltip( "open" );
|
|
|
|
|
2011-05-30 22:51:29 +00:00
|
|
|
element.one( "tooltipclose", function( event, ui ) {
|
2016-04-06 13:59:12 +00:00
|
|
|
assert.ok( !( "originalEvent" in event ), "close" );
|
|
|
|
assert.strictEqual( ui.tooltip[ 0 ], tooltip[ 0 ], "ui.tooltip" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2011-05-28 20:20:46 +00:00
|
|
|
element.tooltip( "close" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2016-04-06 13:59:12 +00:00
|
|
|
QUnit.test( "mouse events", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2011-05-28 20:20:46 +00:00
|
|
|
var element = $( "#tooltipped1" ).tooltip();
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipopen", function( event ) {
|
2016-04-06 13:59:12 +00:00
|
|
|
assert.deepEqual( event.originalEvent.type, "mouseover" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2011-05-28 20:20:46 +00:00
|
|
|
element.trigger( "mouseover" );
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipclose", function( event ) {
|
2016-04-06 13:59:12 +00:00
|
|
|
assert.deepEqual( event.originalEvent.type, "mouseleave" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2012-10-21 17:07:43 +00:00
|
|
|
element.trigger( "focusout" );
|
2011-05-28 20:20:46 +00:00
|
|
|
element.trigger( "mouseleave" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2010-04-15 07:45:35 +00:00
|
|
|
|
2016-04-06 13:59:12 +00:00
|
|
|
QUnit.test( "focus events", function( assert ) {
|
|
|
|
assert.expect( 2 );
|
2011-05-28 20:20:46 +00:00
|
|
|
var element = $( "#tooltipped1" ).tooltip();
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipopen", function( event ) {
|
2016-04-06 13:59:12 +00:00
|
|
|
assert.deepEqual( event.originalEvent.type, "focusin" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2011-05-28 20:20:46 +00:00
|
|
|
element.trigger( "focusin" );
|
|
|
|
|
2015-05-14 02:02:14 +00:00
|
|
|
element.on( "tooltipclose", function( event ) {
|
2016-04-06 13:59:12 +00:00
|
|
|
assert.deepEqual( event.originalEvent.type, "focusout" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2012-10-21 17:07:43 +00:00
|
|
|
element.trigger( "mouseleave" );
|
|
|
|
element.trigger( "focusout" );
|
2015-08-24 12:50:46 +00:00
|
|
|
} );
|
2011-05-29 23:21:31 +00:00
|
|
|
|
2015-04-07 00:28:55 +00:00
|
|
|
} );
|