diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/data/testsuite.css | 6 | ||||
-rw-r--r-- | test/unit/core.js | 9 | ||||
-rw-r--r-- | test/unit/css.js | 24 | ||||
-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 | 12 |
8 files changed, 192 insertions, 21 deletions
diff --git a/test/data/testsuite.css b/test/data/testsuite.css index cffaaa46a..d029b8716 100644 --- a/test/data/testsuite.css +++ b/test/data/testsuite.css @@ -1,5 +1,5 @@ /* for testing opacity set in styles in IE */ -ol#empty { opacity: 0; filter:Alpha(opacity=0); } +ol#empty { opacity: 0; filter:Alpha(opacity=0) progid:DXImageTransform.Microsoft.gradient(startColorStr='#ffff0000', EndColorStr='#ffffffff'); } div#fx-tests h4 { background: red; @@ -109,3 +109,7 @@ div#show-tests * { display: none; } #nothiddendiv { font-size: 16px; } #nothiddendivchild.em { font-size: 2em; } #nothiddendivchild.prct { font-size: 150%; } + +div.isimportant { + background-color: rgb(255, 255, 255) !important; +} diff --git a/test/unit/core.js b/test/unit/core.js index c2a23b1a8..74419fffb 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 904312be6..cd2019fe2 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,7 +378,22 @@ 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("$().css override !important css declarations (bug #4427)", function(){ + expect(4); + var div = jQuery("<div/>", { + "class": "isimportant" // background-color: #fff !important + }); + div.css("backgroundColor", "rgb(0, 255, 0)"); + equals( div.css("backgroundColor"), "rgb(0, 255, 0)", "Background color is overrided to rgb(0, 255, 0)" ); + equals( div.css("background-color"), "rgb(0, 255, 0)", "Background color is overrided to rgb(0, 255, 0)" ); + + div.css("background-color", "rgb(0, 255, 0)"); + equals( div.css("backgroundColor"), "rgb(0, 255, 0)", "Background color is overrided to rgb(0, 255, 0)" ); + equals( div.css("background-color"), "rgb(0, 255, 0)", "Background color is overrided to rgb(0, 255, 0)" ); + }); test("jQuery.cssProps behavior, (bug #8402)", function() { @@ -390,4 +408,4 @@ test("jQuery.cssProps behavior, (bug #8402)", function() { equal( div[0].style.left, "100px", "the fixed property is used when setting the style"); // cleanup jQuery.cssProps jQuery.cssProps.top = undefined; -});
\ No newline at end of file +}); diff --git a/test/unit/effects.js b/test/unit/effects.js index 4f6785111..71a81eef7 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 cefdf5833..b1fd919f5 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 ae0518849..198211263 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 31e587db2..05461cd26 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(); + }); +}); diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 6228a0b98..140b337aa 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' ); @@ -223,10 +222,6 @@ test("closest(Array)", function() { same( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" ); }); -<<<<<<< HEAD -test("not(Selector|undefined)", function() { - expect(11); -======= test("closest(jQuery)", function() { expect(8); var $child = jQuery("#nothiddendivchild"), @@ -243,9 +238,8 @@ test("closest(jQuery)", function() { ok( $child.closest( $body.add($parent) ).is('#nothiddendiv'), "Closest ancestor retrieved." ); }); -test("not(Selector)", function() { - expect(7); ->>>>>>> 1a167767305202797cf4c839eb64bd7adfb00182 +test("not(Selector|undefined)", function() { + expect(11); equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" ); same( jQuery("p").not(".result").get(), q("firstp", "ap", "sndp", "en", "sap", "first"), "not('.class')" ); same( jQuery("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" ); |