diff options
author | louisremi <louisremi@louisremi-laptop.(none)> | 2011-04-12 11:29:25 +0200 |
---|---|---|
committer | louisremi <louisremi@louisremi-laptop.(none)> | 2011-04-12 11:29:25 +0200 |
commit | a5604aedb74ec39624b21229a5c8542c793b0382 (patch) | |
tree | 9fa541ff92d96a8979af260a31f2d75492e696fd /test/unit | |
parent | 8547b34f9265ed2d2b5380b1db5dfcaf97d96d5a (diff) | |
parent | 312df0441b16981dd697d74fcbc1e1f212b47b7e (diff) | |
download | jquery-a5604aedb74ec39624b21229a5c8542c793b0382.tar.gz jquery-a5604aedb74ec39624b21229a5c8542c793b0382.zip |
merge with master and resolve more conflicts
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/core.js | 9 | ||||
-rw-r--r-- | test/unit/css.js | 21 | ||||
-rw-r--r-- | test/unit/effects.js | 2 | ||||
-rw-r--r-- | test/unit/event.js | 21 | ||||
-rw-r--r-- | test/unit/offset.js | 28 | ||||
-rw-r--r-- | test/unit/queue.js | 111 | ||||
-rw-r--r-- | test/unit/traversing.js | 3 |
7 files changed, 183 insertions, 12 deletions
diff --git a/test/unit/core.js b/test/unit/core.js index bb02a0aa6..8d29575a5 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -818,7 +818,7 @@ test("jQuery.extend(Object, Object)", function() { }); test("jQuery.each(Object,Function)", function() { - expect(13); + expect(14); jQuery.each( [0,1,2], function(i, n){ equals( i, n, "Check array iteration" ); }); @@ -850,6 +850,13 @@ test("jQuery.each(Object,Function)", function() { f[i] = "baz"; }); equals( "baz", f.foo, "Loop over a function" ); + + var stylesheet_count = 0; + jQuery.each(document.styleSheets, function(i){ + stylesheet_count++; + }); + equals(stylesheet_count, 2, "should not throw an error in IE while looping over document.styleSheets and return proper amount"); + }); test("jQuery.makeArray", function(){ diff --git a/test/unit/css.js b/test/unit/css.js index 3996fbccf..33bc1548d 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1,7 +1,7 @@ module("css", { teardown: moduleTeardown }); test("css(String|Hash)", function() { - expect(41); + expect( 42 ); equals( jQuery("#main").css("display"), "block", "Check for css property \"display\""); @@ -58,6 +58,9 @@ test("css(String|Hash)", function() { equals( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" ); jQuery("#empty").css({ opacity: "1" }); equals( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" ); + jQuery.support.opacity ? + ok(true, "Requires the same number of tests"): + ok( ~jQuery("#empty")[0].currentStyle.filter.indexOf("gradient"), "Assert setting opacity doesn't overwrite other filters of the stylesheet in IE" ); var div = jQuery("#nothiddendiv"), child = jQuery("#nothiddendivchild"); @@ -375,5 +378,19 @@ test("marginRight computed style (bug #3333)", function() { marginRight: 0 }); - equals($div.css("marginRight"), "0px"); + equals($div.css("marginRight"), "0px", "marginRight correctly calculated with a width and display block"); +}); + +test("jQuery.cssProps behavior, (bug #8402)", function() { + var div = jQuery( "<div>" ).appendTo(document.body).css({ + position: "absolute", + top: 0, + left: 10 + }); + jQuery.cssProps.top = "left"; + equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style"); + div.css("top", "100px"); + equal( div[0].style.left, "100px", "the fixed property is used when setting the style"); + // cleanup jQuery.cssProps + jQuery.cssProps.top = undefined; }); diff --git a/test/unit/effects.js b/test/unit/effects.js index 0979a4c1a..4faf61743 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -807,7 +807,7 @@ jQuery.checkState = function(){ jQuery.removeData(this, "olddisplay", true); start(); -} +}; // Chaining Tests test("Chain fadeOut fadeIn", function() { diff --git a/test/unit/event.js b/test/unit/event.js index d3e57614f..b46ef9ebb 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2022,6 +2022,27 @@ test("delegate with submit", function() { jQuery(document).undelegate(); }); +test("undelegate() with only namespaces", function(){ + expect(2); + + var $delegate = jQuery("#liveHandlerOrder"), + count = 0; + + $delegate.delegate("a", "click.ns", function(e) { + count++; + }); + + jQuery("a", $delegate).eq(0).trigger("click.ns"); + + equals( count, 1, "delegated click.ns"); + + $delegate.undelegate(".ns"); + + jQuery("a", $delegate).eq(1).trigger("click.ns"); + + equals( count, 1, "no more .ns after undelegate"); +}); + test("Non DOM element events", function() { expect(1); diff --git a/test/unit/offset.js b/test/unit/offset.js index a346b657c..f7bda29be 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -433,7 +433,33 @@ test("offsetParent", function(){ equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." ); }); -function testoffset( name, fn ) { +test("fractions (see #7730 and #7885)", function() { + expect(2); + + jQuery('body').append('<div id="fractions"/>'); + + var expected = { top: 1000, left: 1000 }; + var div = jQuery('#fractions'); + + div.css({ + position: 'absolute', + left: '1000.7432222px', + top: '1000.532325px', + width: 100, + height: 100 + }); + + div.offset(expected); + + var result = div.offset(); + + equals( result.top, expected.top, "Check top" ); + equals( result.left, expected.left, "Check left" ); + + div.remove(); +}); + +function testoffset(name, fn) { test(name, function() { // pause execution for now diff --git a/test/unit/queue.js b/test/unit/queue.js index 34f61f826..9b612ce37 100644 --- a/test/unit/queue.js +++ b/test/unit/queue.js @@ -1,10 +1,17 @@ module("queue", { teardown: moduleTeardown }); test("queue() with other types",function() { - expect(9); + expect(11); var counter = 0; - var $div = jQuery({}); + stop(); + + var $div = jQuery({}), + defer; + + $div.promise("foo").done(function() { + equals( counter, 0, "Deferred for collection with no queue is automatically resolved" ); + }); $div .queue("foo",function(){ @@ -22,6 +29,11 @@ test("queue() with other types",function() { equals( ++counter, 4, "Dequeuing" ); }); + defer = $div.promise("foo").done(function() { + equals( counter, 4, "Testing previous call to dequeue in deferred" ); + start(); + }); + equals( $div.queue("foo").length, 4, "Testing queue length" ); $div.dequeue("foo"); @@ -74,7 +86,7 @@ test("queue(name) passes in the next item in the queue as a parameter", function }); test("queue() passes in the next item in the queue as a parameter to fx queues", function() { - expect(2); + expect(3); stop(); var div = jQuery({}); @@ -87,11 +99,15 @@ test("queue() passes in the next item in the queue as a parameter to fx queues", }).queue(function(next) { equals(++counter, 2, "Next was called"); next(); - start(); }).queue("bar", function() { equals(++counter, 3, "Other queues are not triggered by next()") }); + jQuery.when( div.promise("fx"), div ).done(function() { + equals(counter, 2, "Deferreds resolved"); + start(); + }); + }); test("delay()", function() { @@ -110,7 +126,9 @@ test("delay()", function() { }); test("clearQueue(name) clears the queue", function() { - expect(1); + expect(2); + + stop() var div = jQuery({}); var counter = 0; @@ -123,6 +141,11 @@ test("clearQueue(name) clears the queue", function() { counter++; }); + div.promise("foo").done(function() { + ok( true, "dequeue resolves the deferred" ); + start(); + }); + div.dequeue("foo"); equals(counter, 1, "the queue was cleared"); @@ -146,3 +169,81 @@ test("clearQueue() clears the fx queue", function() { div.removeData(); }); + +test("_mark() and _unmark()", function() { + expect(1); + + var div = {}, + $div = jQuery( div ); + + stop(); + + jQuery._mark( div, "foo" ); + jQuery._mark( div, "foo" ); + jQuery._unmark( div, "foo" ); + jQuery._unmark( div, "foo" ); + + $div.promise( "foo" ).done(function() { + ok( true, "No more marks" ); + start(); + }); +}); + +test("_mark() and _unmark() default to 'fx'", function() { + expect(1); + + var div = {}, + $div = jQuery( div ); + + stop(); + + jQuery._mark( div ); + jQuery._mark( div ); + jQuery._unmark( div, "fx" ); + jQuery._unmark( div ); + + $div.promise().done(function() { + ok( true, "No more marks" ); + start(); + }); +}); + +test("promise()", function() { + expect(1); + + stop(); + + var objects = []; + + jQuery.each( [{}, {}], function( i, div ) { + var $div = jQuery( div ); + $div.queue(function( next ) { + setTimeout( function() { + if ( i ) { + next(); + setTimeout( function() { + jQuery._unmark( div ); + }, 20 ); + } else { + jQuery._unmark( div ); + setTimeout( function() { + next(); + }, 20 ); + } + }, 50 ); + }).queue(function( next ) { + next(); + }); + jQuery._mark( div ); + objects.push( $div ); + }); + + jQuery.when.apply( jQuery, objects ).done(function() { + ok( true, "Deferred resolved" ); + start(); + }); + + jQuery.each( objects, function() { + this.dequeue(); + }); +});
\ No newline at end of file diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 1248e5dd8..27f315151 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -72,7 +72,7 @@ test("is(String|undefined)", function() { }); test("is(jQuery)", function() { - expect(24); + expect(23); ok( jQuery("#form").is( jQuery("form") ), "Check for element: A form is a form" ); ok( !jQuery("#form").is( jQuery("div") ), "Check for element: A form is not a div" ); ok( jQuery("#mark").is( jQuery(".blog") ), "Check for class: Expected class 'blog'" ); @@ -83,7 +83,6 @@ test("is(jQuery)", function() { ok( !jQuery("#en").is( jQuery("[lang=\"de\"]") ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" ); ok( jQuery("#text1").is( jQuery("[type=\"text\"]") ), "Check for attribute: Expected attribute type to be 'text'" ); ok( !jQuery("#text1").is( jQuery("[type=\"radio\"]") ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" ); - ok( jQuery("#text2").is( jQuery(":disabled") ), "Check for pseudoclass: Expected to be disabled" ); ok( !jQuery("#text1").is( jQuery(":disabled") ), "Check for pseudoclass: Expected not disabled" ); ok( jQuery("#radio2").is( jQuery(":checked") ), "Check for pseudoclass: Expected to be checked" ); ok( !jQuery("#radio1").is( jQuery(":checked") ), "Check for pseudoclass: Expected not checked" ); |