aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJörn Zaefferer <joern.zaefferer@gmail.com>2011-06-02 14:11:55 +0200
committerJörn Zaefferer <joern.zaefferer@gmail.com>2011-06-02 14:11:55 +0200
commit8deb745a4a29351ef1f1e240b06e10bbb37579e5 (patch)
treedae42f89f3bfc24bd5709657c9f8b9614ee7f8fd /tests
parentafe0f72945170879571ebaf060a816b39c9871b8 (diff)
parent2a27499ee4ab8076f7c342934af63ad4827f2533 (diff)
downloadjquery-ui-8deb745a4a29351ef1f1e240b06e10bbb37579e5.tar.gz
jquery-ui-8deb745a4a29351ef1f1e240b06e10bbb37579e5.zip
Merge branch 'master' into widget-factory-demo
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/tooltip/tooltip_defaults.js6
-rw-r--r--tests/unit/tooltip/tooltip_events.js13
-rw-r--r--tests/unit/widget/widget.html1
-rw-r--r--tests/unit/widget/widget_animation.js257
4 files changed, 272 insertions, 5 deletions
diff --git a/tests/unit/tooltip/tooltip_defaults.js b/tests/unit/tooltip/tooltip_defaults.js
index ded3d4558..4b687bdcb 100644
--- a/tests/unit/tooltip/tooltip_defaults.js
+++ b/tests/unit/tooltip/tooltip_defaults.js
@@ -2,15 +2,19 @@ commonWidgetTests( "tooltip", {
defaults: {
content: function() {},
disabled: false,
+ hide: true,
items: "[title]",
position: {
my: "left+15 center",
at: "right center",
collision: "flip fit"
},
+ show: true,
tooltipClass: null,
// callbacks
- create: null
+ close: null,
+ create: null,
+ open: null
}
});
diff --git a/tests/unit/tooltip/tooltip_events.js b/tests/unit/tooltip/tooltip_events.js
index 61026882e..29220705f 100644
--- a/tests/unit/tooltip/tooltip_events.js
+++ b/tests/unit/tooltip/tooltip_events.js
@@ -3,16 +3,21 @@
module( "tooltip: events" );
test( "programmatic triggers", function() {
- expect( 2 );
- var element = $( "#tooltipped1" ).tooltip();
+ expect( 4 );
+ var tooltip,
+ element = $( "#tooltipped1" ).tooltip();
- element.one( "tooltipopen", function( event ) {
+ element.one( "tooltipopen", function( event, ui ) {
+ tooltip = ui.tooltip;
ok( !( "originalEvent" in event ), "open" );
+ strictEqual( ui.tooltip[0],
+ $( "#" + element.attr( "aria-describedby" ) )[0], "ui.tooltip" );
});
element.tooltip( "open" );
- element.one( "tooltipclose", function( event ) {
+ element.one( "tooltipclose", function( event, ui ) {
ok( !( "originalEvent" in event ), "close" );
+ strictEqual( ui.tooltip[0], tooltip[0], "ui.tooltip" );
});
element.tooltip( "close" );
});
diff --git a/tests/unit/widget/widget.html b/tests/unit/widget/widget.html
index 183537612..b06aa19f8 100644
--- a/tests/unit/widget/widget.html
+++ b/tests/unit/widget/widget.html
@@ -15,6 +15,7 @@
<script src="widget_core.js"></script>
<script src="widget_extend.js"></script>
+ <script src="widget_animation.js"></script>
<script src="../swarminject.js"></script>
</head>
diff --git a/tests/unit/widget/widget_animation.js b/tests/unit/widget/widget_animation.js
new file mode 100644
index 000000000..8ef55aa11
--- /dev/null
+++ b/tests/unit/widget/widget_animation.js
@@ -0,0 +1,257 @@
+
+module( "widget animation", (function() {
+ var show = $.fn.show,
+ fadeIn = $.fn.fadeIn,
+ slideDown = $.fn.slideDown;
+ return {
+ setup: function() {
+ $.widget( "ui.testWidget", {
+ _create: function() {
+ this.element.hide();
+ },
+ show: function( fn ) {
+ this._show( this.element, this.options.show, fn );
+ }
+ });
+ $.effects = { effect: { testEffect: $.noop } };
+ },
+ teardown: function() {
+ delete $.ui.testWidget;
+ delete $.effects.effect.testEffect;
+ $.fn.show = show;
+ $.fn.fadeIn = fadeIn;
+ $.fn.slideDown = slideDown;
+ }
+ };
+}()));
+
+asyncTest( "show: null", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget(),
+ hasRun = false;
+ $.fn.show = function() {
+ ok( true, "show called" );
+ equal( arguments.length, 0, "no args passed to show" );
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: true", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: true
+ }),
+ hasRun = false;
+ $.fn.fadeIn = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ strictEqual( duration, undefined, "duration" );
+ strictEqual( easing, undefined, "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: number", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: 123
+ }),
+ hasRun = false;
+ $.fn.fadeIn = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ strictEqual( duration, 123, "duration" );
+ strictEqual( easing, undefined, "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: core animation", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: "slideDown"
+ }),
+ hasRun = false;
+ $.fn.slideDown = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ strictEqual( duration, undefined, "duration" );
+ strictEqual( easing, undefined, "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: effect", function() {
+ expect( 5 );
+
+ var element = $( "#widget" ).testWidget({
+ show: "testEffect"
+ }),
+ hasRun = false;
+ $.fn.show = function( options ) {
+ return this.queue(function( next ) {
+ equal( options.effect, "testEffect", "effect" );
+ ok( !("duration" in options), "duration" );
+ ok( !("easing" in options), "easing" );
+ options.complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: object(core animation)", function() {
+ expect( 4 );
+
+ var element = $( "#widget" ).testWidget({
+ show: {
+ effect: "slideDown",
+ duration: 123,
+ easing: "testEasing"
+ }
+ }),
+ hasRun = false;
+ $.fn.slideDown = function( duration, easing, complete ) {
+ return this.queue(function( next ) {
+ equal( duration, 123, "duration" );
+ equal( easing, "testEasing", "easing" );
+ complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});
+
+asyncTest( "show: object(effect)", function() {
+ expect( 3 );
+
+ var element = $( "#widget" ).testWidget({
+ show: {
+ effect: "testEffect",
+ duration: 123,
+ easing: "testEasing"
+ }
+ }),
+ hasRun = false;
+ $.fn.show = function( options ) {
+ return this.queue(function( next ) {
+ deepEqual( options, {
+ effect: "testEffect",
+ duration: 123,
+ easing: "testEasing",
+ complete: options.complete
+ });
+ options.complete();
+ next();
+ });
+ };
+
+ element
+ .delay( 50 )
+ .queue(function( next ) {
+ ok( !hasRun, "queue before show" );
+ next();
+ })
+ .testWidget( "show", function() {
+ hasRun = true;
+ })
+ .queue(function( next ) {
+ ok( hasRun, "queue after show" );
+ start();
+ next();
+ });
+});