Commit ba48be3a authored by Ariel Flesler's avatar Ariel Flesler

test runner: translated all the ok() with '==' to equals(), as it gives more...

test runner: translated all the ok() with '==' to equals(), as it gives more information on failures.
parent e5e24bd3
......@@ -167,8 +167,8 @@ test("$.ajax - dataType html", function() {
testFoo = undefined;
var verifyEvaluation = function() {
ok( testFoo == "foo", 'Check if script was evaluated for datatype html' );
ok( foobar == "bar", 'Check if script src was evaluated for datatype html' );
equals( testFoo, "foo", 'Check if script was evaluated for datatype html' );
equals( foobar, "bar", 'Check if script src was evaluated for datatype html' );
start();
};
......@@ -383,8 +383,8 @@ test("load(String, Function) - check file with only a script tag", function() {
stop();
testFoo = undefined;
$('#first').load(url('data/test2.html'), function() {
ok( $('#foo').html() == 'foo', 'Check if script evaluation has modified DOM');
ok( testFoo == "foo", 'Check if script was evaluated after load' );
equals( $('#foo').html(), 'foo', 'Check if script evaluation has modified DOM');
equals( testFoo, "foo", 'Check if script was evaluated after load' );
start();
});
});
......@@ -652,10 +652,10 @@ test("$.getJSON(String, Hash, Function) - JSON array", function() {
expect(4);
stop();
$.getJSON(url("data/json.php"), {json: "array"}, function(json) {
ok( json[0].name == 'John', 'Check JSON: first, name' );
ok( json[0].age == 21, 'Check JSON: first, age' );
ok( json[1].name == 'Peter', 'Check JSON: second, name' );
ok( json[1].age == 25, 'Check JSON: second, age' );
equals( json[0].name, 'John', 'Check JSON: first, name' );
equals( json[0].age, 21, 'Check JSON: first, age' );
equals( json[1].name, 'Peter', 'Check JSON: second, name' );
equals( json[1].age, 25, 'Check JSON: second, age' );
start();
});
});
......@@ -664,8 +664,8 @@ test("$.getJSON(String, Function) - JSON object", function() {
expect(2);
stop();
$.getJSON(url("data/json.php"), function(json) {
ok( json.data.lang == 'en', 'Check JSON: lang' );
ok( json.data.length == 25, 'Check JSON: length' );
equals( json.data.lang, 'en', 'Check JSON: lang' );
equals( json.data.length, 25, 'Check JSON: length' );
start();
});
});
......@@ -677,8 +677,8 @@ test("$.getJSON(String, Function) - JSON object with absolute url to local conte
stop();
$.getJSON(url(base + "data/json.php"), function(json) {
ok( json.data.lang == 'en', 'Check JSON: lang' );
ok( json.data.length == 25, 'Check JSON: length' );
equals( json.data.lang, 'en', 'Check JSON: lang' );
equals( json.data.length, 25, 'Check JSON: length' );
start();
});
});
......@@ -688,15 +688,15 @@ test("$.post(String, Hash, Function) - simple with xml", function() {
stop();
$.post(url("data/name.php"), {xml: "5-2"}, function(xml){
$('math', xml).each(function() {
ok( $('calculation', this).text() == '5-2', 'Check for XML' );
ok( $('result', this).text() == '3', 'Check for XML' );
equals( $('calculation', this).text(), '5-2', 'Check for XML' );
equals( $('result', this).text(), '3', 'Check for XML' );
});
});
$.post(url("data/name.php?xml=5-2"), {}, function(xml){
$('math', xml).each(function() {
ok( $('calculation', this).text() == '5-2', 'Check for XML' );
ok( $('result', this).text() == '3', 'Check for XML' );
equals( $('calculation', this).text(), '5-2', 'Check for XML' );
equals( $('result', this).text(), '3', 'Check for XML' );
});
start();
});
......@@ -765,7 +765,7 @@ test("$.ajax - simple get", function() {
type: "GET",
url: url("data/name.php?name=foo"),
success: function(msg){
ok( msg == 'bar', 'Check for GET' );
equals( msg, 'bar', 'Check for GET' );
start();
}
});
......@@ -779,7 +779,7 @@ test("$.ajax - simple post", function() {
url: url("data/name.php"),
data: "name=peter",
success: function(msg){
ok( msg == 'pan', 'Check for POST' );
equals( msg, 'pan', 'Check for POST' );
start();
}
});
......@@ -791,7 +791,7 @@ test("ajaxSetup()", function() {
$.ajaxSetup({
url: url("data/name.php?name=foo"),
success: function(msg){
ok( msg == 'bar', 'Check for GET' );
equals( msg, 'bar', 'Check for GET' );
start();
}
});
......
This diff is collapsed.
......@@ -4,7 +4,7 @@ test("bind(), with data", function() {
expect(3);
var handler = function(event) {
ok( event.data, "bind() with data, check passed data exists" );
ok( event.data.foo == "bar", "bind() with data, Check value of passed data" );
equals( event.data.foo, "bar", "bind() with data, Check value of passed data" );
};
$("#firstp").bind("click", {foo: "bar"}, handler).click().unbind("click", handler);
......@@ -15,9 +15,9 @@ test("bind(), with data, trigger with data", function() {
expect(4);
var handler = function(event, data) {
ok( event.data, "check passed data exists" );
ok( event.data.foo == "bar", "Check value of passed data" );
equals( event.data.foo, "bar", "Check value of passed data" );
ok( data, "Check trigger data" );
ok( data.bar == "foo", "Check value of trigger data" );
equals( data.bar, "foo", "Check value of trigger data" );
};
$("#firstp").bind("click", {foo: "bar"}, handler).trigger("click", [{bar: "foo"}]).unbind("click", handler);
});
......@@ -33,8 +33,8 @@ test("bind(), multiple events at once", function() {
mouseoverCounter += 1;
};
$("#firstp").bind("click mouseover", handler).trigger("click").trigger("mouseover");
ok( clickCounter == 1, "bind() with multiple events at once" );
ok( mouseoverCounter == 1, "bind() with multiple events at once" );
equals( clickCounter, 1, "bind() with multiple events at once" );
equals( mouseoverCounter, 1, "bind() with multiple events at once" );
});
test("bind(), no data", function() {
......@@ -116,7 +116,7 @@ test("click()", function() {
expect(5);
$('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {
var close = $('spanx', this); // same with $(this).find('span');
ok( close.length == 0, "Context element does not exist, length must be zero" );
equals( close.length, 0, "Context element does not exist, length must be zero" );
ok( !close[0], "Context element does not exist, direct access to element must return undefined" );
return false;
}).click();
......@@ -130,14 +130,14 @@ test("click()", function() {
counter++;
};
$('#firstp').click();
ok( counter == 1, "Check that click, triggers onclick event handler also" );
equals( counter, 1, "Check that click, triggers onclick event handler also" );
var clickCounter = 0;
$('#simon1')[0].onclick = function(event) {
clickCounter++;
};
$('#simon1').click();
ok( clickCounter == 1, "Check that click, triggers onclick event handler on an a tag also" );
equals( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" );
});
test("unbind(event)", function() {
......@@ -173,8 +173,8 @@ test("unbind(event)", function() {
mouseoverCounter += 1;
};
$("#firstp").bind("click mouseover", handler).unbind("click mouseover", handler).trigger("click").trigger("mouseover");
ok( clickCounter == 0, "unbind() with multiple events at once" );
ok( mouseoverCounter == 0, "unbind() with multiple events at once" );
equals( clickCounter, 0, "unbind() with multiple events at once" );
equals( mouseoverCounter, 0, "unbind() with multiple events at once" );
});
test("trigger(event, [data], [fn])", function() {
......@@ -280,7 +280,7 @@ test("toggle(Function, Function, ...)", function() {
preventDefault = function(e) { e.preventDefault() },
link = $('#mark');
link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click();
ok( count == 1, "Check for toggle(fn, fn)" );
equals( count, 1, "Check for toggle(fn, fn)" );
$("#firstp").toggle(function () {
equals(arguments.length, 4, "toggle correctly passes through additional triggered arguments, see #1701" )
......@@ -290,9 +290,9 @@ test("toggle(Function, Function, ...)", function() {
$("#simon1").one("click", function() {
ok( true, "Execute event only once" );
$(this).toggle(function() {
ok( first++ == 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
equals( first++, 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
}, function() {
ok( first == 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
equals( first, 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" );
});
return false;
}).click().click().click();
......@@ -312,15 +312,15 @@ test("toggle(Function, Function, ...)", function() {
var $div = $("<div>&nbsp;</div>").toggle( fns[0], fns[1], fns[2] );
$div.click();
ok( turn == 1, "Trying toggle with 3 functions, attempt 1 yields 1");
equals( turn, 1, "Trying toggle with 3 functions, attempt 1 yields 1");
$div.click();
ok( turn == 2, "Trying toggle with 3 functions, attempt 2 yields 2");
equals( turn, 2, "Trying toggle with 3 functions, attempt 2 yields 2");
$div.click();
ok( turn == 3, "Trying toggle with 3 functions, attempt 3 yields 3");
equals( turn, 3, "Trying toggle with 3 functions, attempt 3 yields 3");
$div.click();
ok( turn == 1, "Trying toggle with 3 functions, attempt 4 yields 1");
equals( turn, 1, "Trying toggle with 3 functions, attempt 4 yields 1");
$div.click();
ok( turn == 2, "Trying toggle with 3 functions, attempt 5 yields 2");
equals( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2");
$div.unbind('click',fns[0]);
var data = $.data( $div[0], 'events' );
......
......@@ -6,7 +6,7 @@ test("animate(Hash, Object, Function)", function() {
var hash = {opacity: 'show'};
var hashCopy = $.extend({}, hash);
$('#foo').animate(hash, 0, function() {
ok( hash.opacity == hashCopy.opacity, 'Check if animate changed the hash parameter' );
equals( hash.opacity, hashCopy.opacity, 'Check if animate changed the hash parameter' );
start();
});
});
......@@ -236,8 +236,8 @@ var to = {
function checkOverflowDisplay(){
var o = jQuery.css( this, "overflow" );
ok(o == "visible", "Overflow should be visible: " + o);
ok(jQuery.css( this, "display" ) == "inline", "Display shouldn't be tampered with.");
equals(o, "visible", "Overflow should be visible: " + o);
equals(jQuery.css( this, "display" ), "inline", "Display shouldn't be tampered with.");
start();
}
......@@ -298,31 +298,31 @@ jQuery.each( from, function(fn, f){
elem.animate(anim, 50, function(){
if ( t_w == "show" )
ok( this.style.display == "block", "Showing, display should block: " + this.style.display);
equals( this.style.display, "block", "Showing, display should block: " + this.style.display);
if ( t_w == "hide"||t_w == "show" )
ok(this.style.width.indexOf(f_w) == 0, "Width must be reset to " + f_w + ": " + this.style.width);
equals(this.style.width.indexOf(f_w), 0, "Width must be reset to " + f_w + ": " + this.style.width);
if ( t_h == "hide"||t_h == "show" )
ok(this.style.height.indexOf(f_h) == 0, "Height must be reset to " + f_h + ": " + this.style.height);
equals(this.style.height.indexOf(f_h), 0, "Height must be reset to " + f_h + ": " + this.style.height);
var cur_o = jQuery.attr(this.style, "opacity");
if ( cur_o !== "" ) cur_o = parseFloat( cur_o );
if ( t_o == "hide"||t_o == "show" )
ok(cur_o == f_o, "Opacity must be reset to " + f_o + ": " + cur_o);
equals(cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o);
if ( t_w == "hide" )
ok(this.style.display == "none", "Hiding, display should be none: " + this.style.display);
equals(this.style.display, "none", "Hiding, display should be none: " + this.style.display);
if ( t_o.constructor == Number ) {
ok(cur_o == t_o, "Final opacity should be " + t_o + ": " + cur_o);
equals(cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o);
ok(jQuery.curCSS(this, "opacity") != "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o);
}
if ( t_w.constructor == Number ) {
ok(this.style.width == t_w + "px", "Final width should be " + t_w + ": " + this.style.width);
equals(this.style.width, t_w + "px", "Final width should be " + t_w + ": " + this.style.width);
var cur_w = jQuery.css(this,"width");
......@@ -330,7 +330,7 @@ jQuery.each( from, function(fn, f){
}
if ( t_h.constructor == Number ) {
ok(this.style.height == t_h + "px", "Final height should be " + t_h + ": " + this.style.height);
equals(this.style.height, t_h + "px", "Final height should be " + t_h + ": " + this.style.height);
var cur_h = jQuery.css(this,"height");
......@@ -367,7 +367,7 @@ function checkState(){
var self = this;
jQuery.each(this.save, function(c,v){
var cur = jQuery.css(self,c);
ok( v == cur, "Make sure that " + c + " is reset (Old: " + v + " Cur: " + cur + ")");
equals( v, cur, "Make sure that " + c + " is reset (Old: " + v + " Cur: " + cur + ")");
});
start();
}
......
......@@ -12,7 +12,7 @@ test("element", function() {
t( "Element Selector", "body", ["body"] );
t( "Element Selector", "html", ["html"] );
t( "Parent Element", "div p", ["firstp","ap","sndp","en","sap","first"] );
ok( $("param", "#object1").length == 2, "Object/param as context" );
equals( $("param", "#object1").length, 2, "Object/param as context" );
ok( $("#length").length, '&lt;input name="length"&gt; cannot be found under IE, see #945' );
ok( $("#lengthtest input").length, '&lt;input name="length"&gt; cannot be found under IE, see #945' );
......@@ -23,7 +23,7 @@ if ( location.protocol != "file:" ) {
expect(1);
stop();
$.get("data/with_fries.xml", function(xml) {
ok( $("foo_bar", xml).length == 1, "Element Selector with underscore" );
equals( $("foo_bar", xml).length, 1, "Element Selector with underscore" );
start();
});
});
......@@ -67,8 +67,8 @@ test("id", function() {
t( "All Children of ID with no children", "#firstUL/*", [] );
$('<a name="tName1">tName1 A</a><a name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main');
ok( $("#tName1")[0].id == 'tName1', "ID selector with same value for a name attribute" );
ok( $("#tName2").length == 0, "ID selector non-existing but name attribute on an A tag" );
equals( $("#tName1")[0].id, 'tName1', "ID selector with same value for a name attribute" );
equals( $("#tName2").length, 0, "ID selector non-existing but name attribute on an A tag" );
t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", ["lengthtest"] );
t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment