aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/dialog/events.js
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/dialog/events.js')
-rw-r--r--tests/unit/dialog/events.js301
1 files changed, 152 insertions, 149 deletions
diff --git a/tests/unit/dialog/events.js b/tests/unit/dialog/events.js
index dd1f4055a..a5030a9f4 100644
--- a/tests/unit/dialog/events.js
+++ b/tests/unit/dialog/events.js
@@ -1,22 +1,23 @@
define( [
+ "qunit",
"jquery",
"./helper",
"ui/widgets/dialog"
-], function( $, testHelper ) {
+], function( QUnit, $, testHelper ) {
-module( "dialog: events" );
+QUnit.module( "dialog: events" );
-test( "open", function() {
- expect( 13 );
+QUnit.test( "open", function( assert ) {
+ assert.expect( 13 );
var element = $( "<div></div>" );
element.dialog( {
open: function( ev, ui ) {
- ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
- ok( true, "autoOpen: true fires open callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogopen", "event type in callback" );
- deepEqual( ui, {}, "ui hash in callback" );
+ assert.ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
+ assert.ok( true, "autoOpen: true fires open callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogopen", "event type in callback" );
+ assert.deepEqual( ui, {}, "ui hash in callback" );
}
} );
element.remove();
@@ -25,23 +26,23 @@ test( "open", function() {
element.dialog( {
autoOpen: false,
open: function( ev, ui ) {
- ok( true, ".dialog('open') fires open callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogopen", "event type in callback" );
- deepEqual( ui, {}, "ui hash in callback" );
+ assert.ok( true, ".dialog('open') fires open callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogopen", "event type in callback" );
+ assert.deepEqual( ui, {}, "ui hash in callback" );
}
} ).on( "dialogopen", function( ev, ui ) {
- ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
- ok( true, "dialog('open') fires open event" );
- equal( this, element[ 0 ], "context of event" );
- deepEqual( ui, {}, "ui hash in event" );
+ assert.ok( element.dialog( "instance" )._isOpen, "interal _isOpen flag is set" );
+ assert.ok( true, "dialog('open') fires open event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.deepEqual( ui, {}, "ui hash in event" );
} );
element.dialog( "open" );
element.remove();
} );
-test( "focus", function() {
- expect( 5 );
+QUnit.test( "focus", function( assert ) {
+ assert.expect( 5 );
var element, other;
element = $( "#dialog1" ).dialog( {
autoOpen: false
@@ -51,27 +52,27 @@ test( "focus", function() {
} );
element.one( "dialogopen", function() {
- ok( true, "open, just once" );
+ assert.ok( true, "open, just once" );
} );
element.one( "dialogfocus", function() {
- ok( true, "focus on open" );
+ assert.ok( true, "focus on open" );
} );
other.dialog( "open" );
element.one( "dialogfocus", function() {
- ok( true, "when opening and already open and wasn't on top" );
+ assert.ok( true, "when opening and already open and wasn't on top" );
} );
other.dialog( "open" );
element.dialog( "open" );
element.one( "dialogfocus", function() {
- ok( true, "when calling moveToTop and wasn't on top" );
+ assert.ok( true, "when calling moveToTop and wasn't on top" );
} );
other.dialog( "moveToTop" );
element.dialog( "moveToTop" );
element.on( "dialogfocus", function() {
- ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
+ assert.ok( true, "when mousedown anywhere on the dialog and it wasn't on top" );
} );
other.dialog( "moveToTop" );
element.trigger( "mousedown" );
@@ -84,23 +85,23 @@ test( "focus", function() {
element.add( other ).remove();
} );
-test( "dragStart", function() {
- expect( 9 );
+QUnit.test( "dragStart", function( assert ) {
+ assert.expect( 9 );
var handle,
element = $( "<div></div>" ).dialog( {
dragStart: function( ev, ui ) {
- ok( true, "dragging fires dragStart callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogdragstart", "event type in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.offset !== undefined, "ui.offset in callback" );
+ assert.ok( true, "dragging fires dragStart callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogdragstart", "event type in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.offset !== undefined, "ui.offset in callback" );
}
} ).on( "dialogdragstart", function( ev, ui ) {
- ok( true, "dragging fires dialogdragstart event" );
- equal( this, element[ 0 ], "context of event" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.offset !== undefined, "ui.offset in callback" );
+ assert.ok( true, "dragging fires dialogdragstart event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.offset !== undefined, "ui.offset in callback" );
} );
handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
@@ -108,27 +109,27 @@ test( "dragStart", function() {
element.remove();
} );
-test( "drag", function() {
- expect( 9 );
+QUnit.test( "drag", function( assert ) {
+ assert.expect( 9 );
var handle,
hasDragged = false,
element = $( "<div></div>" ).dialog( {
drag: function( ev, ui ) {
if ( !hasDragged ) {
- ok( true, "dragging fires drag callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogdrag", "event type in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.offset !== undefined, "ui.offset in callback" );
+ assert.ok( true, "dragging fires drag callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogdrag", "event type in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.offset !== undefined, "ui.offset in callback" );
hasDragged = true;
}
}
} ).one( "dialogdrag", function( ev, ui ) {
- ok( true, "dragging fires dialogdrag event" );
- equal( this, element[ 0 ], "context of event" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.offset !== undefined, "ui.offset in callback" );
+ assert.ok( true, "dragging fires dialogdrag event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.offset !== undefined, "ui.offset in callback" );
} );
handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
@@ -136,23 +137,23 @@ test( "drag", function() {
element.remove();
} );
-test( "dragStop", function() {
- expect( 9 );
+QUnit.test( "dragStop", function( assert ) {
+ assert.expect( 9 );
var handle,
element = $( "<div></div>" ).dialog( {
dragStop: function( ev, ui ) {
- ok( true, "dragging fires dragStop callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogdragstop", "event type in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.offset !== undefined, "ui.offset in callback" );
+ assert.ok( true, "dragging fires dragStop callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogdragstop", "event type in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.offset !== undefined, "ui.offset in callback" );
}
} ).on( "dialogdragstop", function( ev, ui ) {
- ok( true, "dragging fires dialogdragstop event" );
- equal( this, element[ 0 ], "context of event" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.offset !== undefined, "ui.offset in callback" );
+ assert.ok( true, "dragging fires dialogdragstop event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.offset !== undefined, "ui.offset in callback" );
} );
handle = $( ".ui-dialog-titlebar", element.dialog( "widget" ) );
@@ -160,27 +161,27 @@ test( "dragStop", function() {
element.remove();
} );
-test( "resizeStart", function() {
- expect( 13 );
+QUnit.test( "resizeStart", function( assert ) {
+ assert.expect( 13 );
var handle,
element = $( "<div></div>" ).dialog( {
resizeStart: function( ev, ui ) {
- ok( true, "resizing fires resizeStart callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogresizestart", "event type in callback" );
- ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
- ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.size !== undefined, "ui.size in callback" );
+ assert.ok( true, "resizing fires resizeStart callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogresizestart", "event type in callback" );
+ assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.size !== undefined, "ui.size in callback" );
}
} ).on( "dialogresizestart", function( ev, ui ) {
- ok( true, "resizing fires dialogresizestart event" );
- equal( this, element[ 0 ], "context of event" );
- ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
- ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.size !== undefined, "ui.size in callback" );
+ assert.ok( true, "resizing fires dialogresizestart event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.size !== undefined, "ui.size in callback" );
} );
handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
@@ -188,31 +189,31 @@ test( "resizeStart", function() {
element.remove();
} );
-test( "resize", function() {
- expect( 13 );
+QUnit.test( "resize", function( assert ) {
+ assert.expect( 13 );
var handle,
hasResized = false,
element = $( "<div></div>" ).dialog( {
resize: function( ev, ui ) {
if ( !hasResized ) {
- ok( true, "resizing fires resize callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogresize", "event type in callback" );
- ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
- ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.size !== undefined, "ui.size in callback" );
+ assert.ok( true, "resizing fires resize callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogresize", "event type in callback" );
+ assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.size !== undefined, "ui.size in callback" );
hasResized = true;
}
}
} ).one( "dialogresize", function( ev, ui ) {
- ok( true, "resizing fires dialogresize event" );
- equal( this, element[ 0 ], "context of event" );
- ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
- ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.size !== undefined, "ui.size in callback" );
+ assert.ok( true, "resizing fires dialogresize event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.size !== undefined, "ui.size in callback" );
} );
handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
@@ -220,27 +221,27 @@ test( "resize", function() {
element.remove();
} );
-test( "resizeStop", function() {
- expect( 13 );
+QUnit.test( "resizeStop", function( assert ) {
+ assert.expect( 13 );
var handle,
element = $( "<div></div>" ).dialog( {
resizeStop: function( ev, ui ) {
- ok( true, "resizing fires resizeStop callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogresizestop", "event type in callback" );
- ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
- ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.size !== undefined, "ui.size in callback" );
+ assert.ok( true, "resizing fires resizeStop callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogresizestop", "event type in callback" );
+ assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.size !== undefined, "ui.size in callback" );
}
} ).on( "dialogresizestop", function( ev, ui ) {
- ok( true, "resizing fires dialogresizestop event" );
- equal( this, element[ 0 ], "context of event" );
- ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
- ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
- ok( ui.position !== undefined, "ui.position in callback" );
- ok( ui.size !== undefined, "ui.size in callback" );
+ assert.ok( true, "resizing fires dialogresizestop event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.ok( ui.originalPosition !== undefined, "ui.originalPosition in callback" );
+ assert.ok( ui.originalSize !== undefined, "ui.originalSize in callback" );
+ assert.ok( ui.position !== undefined, "ui.position in callback" );
+ assert.ok( ui.size !== undefined, "ui.size in callback" );
} );
handle = $( ".ui-resizable-se", element.dialog( "widget" ) );
@@ -248,20 +249,21 @@ test( "resizeStop", function() {
element.remove();
} );
-asyncTest( "close", function() {
- expect( 14 );
+QUnit.test( "close", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 14 );
var element = $( "<div></div>" ).dialog( {
close: function( ev, ui ) {
- ok( true, ".dialog('close') fires close callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogclose", "event type in callback" );
- deepEqual( ui, {}, "ui hash in callback" );
+ assert.ok( true, ".dialog('close') fires close callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogclose", "event type in callback" );
+ assert.deepEqual( ui, {}, "ui hash in callback" );
}
} ).on( "dialogclose", function( ev, ui ) {
- ok( true, ".dialog('close') fires dialogclose event" );
- equal( this, element[ 0 ], "context of event" );
- deepEqual( ui, {}, "ui hash in event" );
+ assert.ok( true, ".dialog('close') fires dialogclose event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.deepEqual( ui, {}, "ui hash in event" );
} );
element.dialog( "close" );
element.remove();
@@ -270,100 +272,101 @@ asyncTest( "close", function() {
element = $( "<div></div>" ).dialog( {
hide: 10,
close: function( ev, ui ) {
- ok( true, ".dialog('close') fires close callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogclose", "event type in callback" );
- deepEqual( ui, {}, "ui hash in callback" );
- start();
+ assert.ok( true, ".dialog('close') fires close callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogclose", "event type in callback" );
+ assert.deepEqual( ui, {}, "ui hash in callback" );
+ ready();
}
} ).on( "dialogclose", function( ev, ui ) {
- ok( true, ".dialog('close') fires dialogclose event" );
- equal( this, element[ 0 ], "context of event" );
- deepEqual( ui, {}, "ui hash in event" );
+ assert.ok( true, ".dialog('close') fires dialogclose event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.deepEqual( ui, {}, "ui hash in event" );
} );
element.dialog( "close" );
} );
-test( "beforeClose", function() {
- expect( 14 );
+QUnit.test( "beforeClose", function( assert ) {
+ assert.expect( 14 );
var element = $( "<div></div>" ).dialog( {
beforeClose: function( ev, ui ) {
- ok( true, ".dialog('close') fires beforeClose callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogbeforeclose", "event type in callback" );
- deepEqual( ui, {}, "ui hash in callback" );
+ assert.ok( true, ".dialog('close') fires beforeClose callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogbeforeclose", "event type in callback" );
+ assert.deepEqual( ui, {}, "ui hash in callback" );
return false;
}
} );
element.dialog( "close" );
- ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
+ assert.ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
element.remove();
element = $( "<div></div>" ).dialog();
element.dialog( "option", "beforeClose", function( ev, ui ) {
- ok( true, ".dialog('close') fires beforeClose callback" );
- equal( this, element[ 0 ], "context of callback" );
- equal( ev.type, "dialogbeforeclose", "event type in callback" );
- deepEqual( ui, {}, "ui hash in callback" );
+ assert.ok( true, ".dialog('close') fires beforeClose callback" );
+ assert.equal( this, element[ 0 ], "context of callback" );
+ assert.equal( ev.type, "dialogbeforeclose", "event type in callback" );
+ assert.deepEqual( ui, {}, "ui hash in callback" );
return false;
} );
element.dialog( "close" );
- ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
+ assert.ok( element.dialog( "widget" ).is( ":visible" ), "beforeClose callback should prevent dialog from closing" );
element.remove();
element = $( "<div></div>" ).dialog().on( "dialogbeforeclose", function( ev, ui ) {
- ok( true, ".dialog('close') triggers dialogbeforeclose event" );
- equal( this, element[ 0 ], "context of event" );
- deepEqual( ui, {}, "ui hash in event" );
+ assert.ok( true, ".dialog('close') triggers dialogbeforeclose event" );
+ assert.equal( this, element[ 0 ], "context of event" );
+ assert.deepEqual( ui, {}, "ui hash in event" );
return false;
} );
element.dialog( "close" );
- ok( element.dialog( "widget" ).is( ":visible" ), "dialogbeforeclose event should prevent dialog from closing" );
+ assert.ok( element.dialog( "widget" ).is( ":visible" ), "dialogbeforeclose event should prevent dialog from closing" );
element.remove();
} );
// #8789 and #8838
-asyncTest( "ensure dialog's container doesn't scroll on resize and focus", function() {
- expect( 2 );
+QUnit.test( "ensure dialog's container doesn't scroll on resize and focus", function( assert ) {
+ var ready = assert.async();
+ assert.expect( 2 );
var element = $( "#dialog1" ).dialog(),
initialScroll = $( window ).scrollTop();
element.dialog( "option", "height", 600 );
- equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after height change" );
+ assert.equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after height change" );
setTimeout( function() {
$( ".ui-dialog-titlebar-close" ).simulate( "mousedown" );
- equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog" );
+ assert.equal( $( window ).scrollTop(), initialScroll, "scroll hasn't moved after focus moved to dialog" );
element.dialog( "destroy" );
- start();
+ ready();
} );
} );
-test( "#5184: isOpen in dialogclose event is true", function() {
- expect( 3 );
+QUnit.test( "#5184: isOpen in dialogclose event is true", function( assert ) {
+ assert.expect( 3 );
var element = $( "<div></div>" ).dialog( {
close: function() {
- ok( !element.dialog( "isOpen" ), "dialog is not open during close" );
+ assert.ok( !element.dialog( "isOpen" ), "dialog is not open during close" );
}
} );
- ok( element.dialog( "isOpen" ), "dialog is open after init" );
+ assert.ok( element.dialog( "isOpen" ), "dialog is open after init" );
element.dialog( "close" );
- ok( !element.dialog( "isOpen" ), "dialog is not open after close" );
+ assert.ok( !element.dialog( "isOpen" ), "dialog is not open after close" );
element.remove();
} );
-test( "ensure dialog keeps focus when clicking modal overlay", function() {
- expect( 2 );
+QUnit.test( "ensure dialog keeps focus when clicking modal overlay", function( assert ) {
+ assert.expect( 2 );
var element = $( "<div></div>" ).dialog( {
modal: true
} );
- equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is in dialog" );
+ assert.equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is in dialog" );
$( ".ui-widget-overlay" ).simulate( "mousedown" );
- equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is still in dialog" );
+ assert.equal( $( document.activeElement ).closest( ".ui-dialog" ).length, 1, "focus is still in dialog" );
element.remove();
} );