From 8ccab9a11f746d7766834ac8387b8733969bff2b Mon Sep 17 00:00:00 2001 From: Richard Worth Date: Thu, 26 Jun 2008 11:08:49 +0000 Subject: [PATCH] tests dialog - added unit tests for #3017 - Dialog callback scopes --- tests/dialog.js | 78 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 11 deletions(-) diff --git a/tests/dialog.js b/tests/dialog.js index 423cdea79..56be158b6 100644 --- a/tests/dialog.js +++ b/tests/dialog.js @@ -400,17 +400,15 @@ module("dialog: Callbacks"); test("open", function() { expect(4); - el = $(""); - var content = el[0]; + el = $("
"); el.dialog({ open: function(ev, ui) { ok(true, 'autoOpen: true fires open callback'); - equals(this, content, "context of callback"); + equals(this, el[0], "context of callback"); } }); el.remove(); - el = $(""); - var content = el[0]; + el = $("
"); el.dialog({ autoOpen: false, open: function(ev, ui) { @@ -423,27 +421,85 @@ test("open", function() { }); test("dragStart", function() { - ok(false, "missing test"); + expect(1); + el = $("
"); + el.dialog({ + dragStart: function(ev, ui) { + equals(this, el[0], "context of callback"); + } + }); + var handle = $(".ui-dialog-titlebar", dlg()); + drag(handle, 50, 50); + el.remove(); }); test("drag", function() { - ok(false, "missing test"); + var fired = false; + el = $("
"); + el.dialog({ + drag: function(ev, ui) { + fired = true; + equals(this, el[0], "context of callback"); + } + }); + var handle = $(".ui-dialog-titlebar", dlg()); + drag(handle, 50, 50); + ok(fired, "resize fired"); + el.remove(); }); test("dragStop", function() { - ok(false, "missing test"); + expect(1); + el = $("
"); + el.dialog({ + dragStop: function(ev, ui) { + equals(this, el[0], "context of callback"); + } + }); + var handle = $(".ui-dialog-titlebar", dlg()); + drag(handle, 50, 50); + el.remove(); }); test("resizeStart", function() { - ok(false, "missing test"); + expect(1); + el = $("
"); + el.dialog({ + resizeStart: function(ev, ui) { + equals(this, el[0], "context of callback"); + } + }); + var handle = $(".ui-resizable-se", dlg()); + drag(handle, 50, 50); + el.remove(); }); test("resize", function() { - ok(false, "missing test"); + var fired = false; + el = $("
"); + el.dialog({ + resize: function(ev, ui) { + fired = true; + equals(this, el[0], "context of callback"); + } + }); + var handle = $(".ui-resizable-se", dlg()); + drag(handle, 50, 50); + ok(fired, "resize fired"); + el.remove(); }); test("resizeStop", function() { - ok(false, "missing test"); + expect(1); + el = $("
"); + el.dialog({ + resizeStop: function(ev, ui) { + equals(this, el[0], "context of callback"); + } + }); + var handle = $(".ui-resizable-se", dlg()); + drag(handle, 50, 50); + el.remove(); }); test("close", function() {