mirror of
https://github.com/jquery/jquery.git
synced 2025-01-10 18:24:24 +00:00
Added equals helper for easier debugging of failed tests, soon to be used more often, see coreTest.js attr(String) for an example
This commit is contained in:
parent
495ecb70b2
commit
a69aad2242
@ -218,4 +218,22 @@ function t(a,b,c) {
|
|||||||
*/
|
*/
|
||||||
function url(value) {
|
function url(value) {
|
||||||
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
|
return value + (/\?/.test(value) ? "&" : "?") + new Date().getTime() + "" + parseInt(Math.random()*100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that the first two arguments are equal, with an optional message.
|
||||||
|
* Prints out both expected and actual values on failure.
|
||||||
|
*
|
||||||
|
* Prefered to ok( expected == actual, message )
|
||||||
|
*
|
||||||
|
* @example equals( "Expected 2 characters.", v.formatMessage("Expected {0} characters.", 2) );
|
||||||
|
*
|
||||||
|
* @param Object expected
|
||||||
|
* @param Object actual
|
||||||
|
* @param String message (optional)
|
||||||
|
*/
|
||||||
|
function equals(expected, actual, message) {
|
||||||
|
var result = expected == actual;
|
||||||
|
message = message || result ? "okay" : "failed";
|
||||||
|
_config.Test.push( [ result, result ? message + ": " + expected : message + " expected: " + expected + " actual: " + actual ] );
|
||||||
|
}
|
||||||
|
2
src/jquery/coreTest.js
vendored
2
src/jquery/coreTest.js
vendored
@ -87,7 +87,7 @@ test("attr(String)", function() {
|
|||||||
ok( $('#name').attr('name') == "name", 'Check for name attribute' );
|
ok( $('#name').attr('name') == "name", 'Check for name attribute' );
|
||||||
ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
|
ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
|
||||||
ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
|
ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
|
||||||
ok( $('#anchor2').attr('href') == "#2", 'Check for non-absolute href (an anchor)' );
|
equals( "#2", $('#anchor2').attr('href'), 'Check for non-absolute href (an anchor)' );
|
||||||
stop();
|
stop();
|
||||||
$.get("data/dashboard.xml", function(xml) {
|
$.get("data/dashboard.xml", function(xml) {
|
||||||
ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );
|
ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );
|
||||||
|
Loading…
Reference in New Issue
Block a user