Tweaked some of the tests, added in events and fx tests.

This commit is contained in:
John Resig 2007-07-09 00:15:44 +00:00
parent b09043fbf6
commit 54035207fe
4 changed files with 34 additions and 13 deletions

View file

@ -6,7 +6,12 @@ window.location = "test/index.html";
load("dist/jquery.js","build/runtest/testrunner.js"); load("dist/jquery.js","build/runtest/testrunner.js");
// Load the tests // Load the tests
load("src/jquery/coreTest.js","src/selector/selectorTest.js"); load(
"src/jquery/coreTest.js",
"src/selector/selectorTest.js",
"src/event/eventTest.js",
"src/fx/fxTest.js"
);
// Display the results // Display the results
results(); results();

View file

@ -161,3 +161,24 @@ function results(){
function start(){} function start(){}
function stop(){} function stop(){}
/**
* Trigger an event on an element.
*
* @example triggerEvent( document.body, "click" );
*
* @param DOMElement elem
* @param String type
*/
function triggerEvent( elem, type, event ) {
/*
if ( jQuery.browser.mozilla || jQuery.browser.opera ) {
event = document.createEvent("MouseEvents");
event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView,
0, 0, 0, 0, 0, false, false, false, false, 0, null);
elem.dispatchEvent( event );
} else if ( jQuery.browser.msie ) {
elem.fireEvent("on"+type);
}
*/
}

View file

@ -28,22 +28,17 @@ test("bind()", function() {
// events don't work with iframes, see #939 // events don't work with iframes, see #939
var tmp = document.createElement('iframe'); var doc = document.getElementById("iframe").contentDocument;
document.body.appendChild( tmp );
var doc = tmp.contentWindow.document; doc.body.innerHTML = "<input type='text'/>";
doc.open();
doc.write("<html><body><input type='text'/></body></html>");
doc.close();
var input = doc.getElementsByTagName("input")[0]; var input = doc.getElementsByTagName("input")[0];
$(input).bind("click",function() { $(input).bind("click",function() {
ok( true, "Binding to element inside iframe" ); ok( true, "Binding to element inside iframe" );
}); }).click();
triggerEvent( input, "click" ); //triggerEvent( input, "click" );
document.body.removeChild( tmp );
var counter = 0; var counter = 0;
function selectOnChange(event) { function selectOnChange(event) {

View file

@ -340,7 +340,7 @@ test("wrap(String|Element)", function() {
ok( result.text() == defaultText, 'Check for element wrapping' ); ok( result.text() == defaultText, 'Check for element wrapping' );
reset(); reset();
stop(); //stop();
$('#check1').click(function() { $('#check1').click(function() {
var checkbox = this; var checkbox = this;
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );