/**
- * QUnit - A JavaScript Unit Testing Framework
+ * QUnit v1.3.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
- * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
color: #fff;
}
+#qunit-header label {
+ display: inline-block;
+}
+
#qunit-banner {
height: 5px;
}
color: #710909;
background-color: #fff;
border-left: 26px solid #EE5757;
+ white-space: pre;
}
#qunit-tests > li:last-child {
position: absolute;
top: -10000px;
left: -10000px;
+ width: 1000px;
+ height: 1000px;
}
/**
- * QUnit - A JavaScript Unit Testing Framework
+ * QUnit v1.3.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
- * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
var defined = {
setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() {
+ var x = "qunit-test-string";
try {
- return !!sessionStorage.getItem;
- } catch(e){
+ sessionStorage.setItem(x, x);
+ sessionStorage.removeItem(x);
+ return true;
+ } catch(e) {
return false;
}
- })()
+ })()
};
-var testId = 0;
+var testId = 0,
+ toString = Object.prototype.toString,
+ hasOwn = Object.prototype.hasOwnProperty;
-var Test = function(name, testName, expected, testEnvironmentArg, async, callback) {
+var Test = function(name, testName, expected, async, callback) {
this.name = name;
this.testName = testName;
this.expected = expected;
- this.testEnvironmentArg = testEnvironmentArg;
this.async = async;
this.callback = callback;
this.assertions = [];
setup: function() {
if (this.module != config.previousModule) {
if ( config.previousModule ) {
- QUnit.moduleDone( {
+ runLoggingCallbacks('moduleDone', QUnit, {
name: config.previousModule,
failed: config.moduleStats.bad,
passed: config.moduleStats.all - config.moduleStats.bad,
}
config.previousModule = this.module;
config.moduleStats = { all: 0, bad: 0 };
- QUnit.moduleStart( {
+ runLoggingCallbacks( 'moduleStart', QUnit, {
+ name: this.module
+ } );
+ } else if (config.autorun) {
+ runLoggingCallbacks( 'moduleStart', QUnit, {
name: this.module
} );
}
setup: function() {},
teardown: function() {}
}, this.moduleTestEnvironment);
- if (this.testEnvironmentArg) {
- extend(this.testEnvironment, this.testEnvironmentArg);
- }
- QUnit.testStart( {
- name: this.testName
- } );
+ runLoggingCallbacks( 'testStart', QUnit, {
+ name: this.testName,
+ module: this.module
+ });
// allow utility functions to access the current test environment
// TODO why??
}
},
run: function() {
+ config.current = this;
if ( this.async ) {
QUnit.stop();
}
// Restart the tests if they're blocking
if ( config.blocking ) {
- start();
+ QUnit.start();
}
}
},
teardown: function() {
+ config.current = this;
try {
this.testEnvironment.teardown.call(this.testEnvironment);
checkPollution();
}
},
finish: function() {
- if ( this.expected && this.expected != this.assertions.length ) {
+ config.current = this;
+ if ( this.expected != null && this.expected != this.assertions.length ) {
QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
}
config.moduleStats.all += this.assertions.length;
if ( tests ) {
- var ol = document.createElement("ol");
+ var ol = document.createElement("ol");
for ( var i = 0; i < this.assertions.length; i++ ) {
var assertion = this.assertions[i];
fail("reset() failed, following Test " + this.testName + ", exception and reset fn follows", e, QUnit.reset);
}
- QUnit.testDone( {
+ runLoggingCallbacks( 'testDone', QUnit, {
name: this.testName,
+ module: this.module,
failed: bad,
passed: this.assertions.length - bad,
total: this.assertions.length
if (bad) {
run();
} else {
- synchronize(run);
+ synchronize(run, true);
};
}
asyncTest: function(testName, expected, callback) {
if ( arguments.length === 2 ) {
callback = expected;
- expected = 0;
+ expected = null;
}
QUnit.test(testName, expected, callback, true);
},
test: function(testName, expected, callback, async) {
- var name = '<span class="test-name">' + testName + '</span>', testEnvironmentArg;
+ var name = '<span class="test-name">' + escapeInnerText(testName) + '</span>';
if ( arguments.length === 2 ) {
callback = expected;
expected = null;
}
- // is 2nd argument a testEnvironment?
- if ( expected && typeof expected === 'object') {
- testEnvironmentArg = expected;
- expected = null;
- }
if ( config.currentModule ) {
name = '<span class="module-name">' + config.currentModule + "</span>: " + name;
return;
}
- var test = new Test(name, testName, expected, testEnvironmentArg, async, callback);
+ var test = new Test(name, testName, expected, async, callback);
test.module = config.currentModule;
test.moduleTestEnvironment = config.currentModuleTestEnviroment;
test.queue();
* @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
*/
ok: function(a, msg) {
+ if (!config.current) {
+ throw new Error("ok() assertion outside test context, was " + sourceFromStacktrace(2));
+ }
a = !!a;
var details = {
result: a,
message: msg
};
- msg = escapeHtml(msg);
- QUnit.log(details);
+ msg = escapeInnerText(msg);
+ runLoggingCallbacks( 'log', QUnit, details );
config.current.assertions.push({
result: a,
message: msg
QUnit.ok(ok, message);
},
- start: function() {
- config.semaphore--;
+ start: function(count) {
+ config.semaphore -= count || 1;
if (config.semaphore > 0) {
// don't start until equal number of stop-calls
return;
// A slight delay, to avoid any current callbacks
if ( defined.setTimeout ) {
window.setTimeout(function() {
+ if (config.semaphore > 0) {
+ return;
+ }
if ( config.timeout ) {
clearTimeout(config.timeout);
}
config.blocking = false;
- process();
+ process(true);
}, 13);
} else {
config.blocking = false;
- process();
+ process(true);
}
},
- stop: function(timeout) {
- config.semaphore++;
+ stop: function(count) {
+ config.semaphore += count || 1;
config.blocking = true;
- if ( timeout && defined.setTimeout ) {
+ if ( config.testTimeout && defined.setTimeout ) {
clearTimeout(config.timeout);
config.timeout = window.setTimeout(function() {
QUnit.ok( false, "Test timed out" );
+ config.semaphore = 1;
QUnit.start();
- }, timeout);
+ }, config.testTimeout);
}
}
};
-// Backwards compatibility, deprecated
-QUnit.equals = QUnit.equal;
-QUnit.same = QUnit.deepEqual;
+//We want access to the constructor's prototype
+(function() {
+ function F(){};
+ F.prototype = QUnit;
+ QUnit = new F();
+ //Make F QUnit's constructor so that we can add to the prototype later
+ QUnit.constructor = F;
+})();
+
+// deprecated; still export them to window to provide clear error messages
+// next step: remove entirely
+QUnit.equals = function() {
+ throw new Error("QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead");
+};
+QUnit.same = function() {
+ throw new Error("QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead");
+};
// Maintain internal state
var config = {
// block until document ready
blocking: true,
+ // when enabled, show only failing tests
+ // gets persisted through sessionStorage and can be changed in UI via checkbox
+ hidepassed: false,
+
// by default, run previously failed tests first
// very useful in combination with "Hide passed tests" checked
reorder: true,
- noglobals: false,
- notrycatch: false
+ // by default, modify document.title when suite is done
+ altertitle: true,
+
+ urlConfig: ['noglobals', 'notrycatch'],
+
+ //logging callback queues
+ begin: [],
+ done: [],
+ log: [],
+ testStart: [],
+ testDone: [],
+ moduleStart: [],
+ moduleDone: []
};
// Load paramaters
// allow just a key to turn on a flag, e.g., test.html?noglobals
current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true;
urlParams[ current[ 0 ] ] = current[ 1 ];
- if ( current[ 0 ] in config ) {
- config[ current[ 0 ] ] = current[ 1 ];
- }
}
}
extend(window, QUnit);
window.QUnit = QUnit;
} else {
- extend(exports, QUnit);
- exports.QUnit = QUnit;
+ module.exports = QUnit;
}
// define these after exposing globals to keep them in these QUnit namespace only
semaphore: 0
});
+ var qunit = id( "qunit" );
+ if ( qunit ) {
+ qunit.innerHTML =
+ '<h1 id="qunit-header">' + escapeInnerText( document.title ) + '</h1>' +
+ '<h2 id="qunit-banner"></h2>' +
+ '<div id="qunit-testrunner-toolbar"></div>' +
+ '<h2 id="qunit-userAgent"></h2>' +
+ '<ol id="qunit-tests"></ol>';
+ }
+
var tests = id( "qunit-tests" ),
banner = id( "qunit-banner" ),
result = id( "qunit-testresult" );
/**
* Resets the test setup. Useful for tests that modify the DOM.
*
- * If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
+ * If jQuery is available, uses jQuery's replaceWith(), otherwise use replaceChild
*/
reset: function() {
- if ( window.jQuery ) {
- jQuery( "#qunit-fixture" ).html( config.fixture );
- } else {
- var main = id( 'qunit-fixture' );
- if ( main ) {
- main.innerHTML = config.fixture;
+ var main = id( 'qunit-fixture' );
+ if ( main ) {
+ if ( window.jQuery ) {
+ jQuery( main ).replaceWith( config.fixture.cloneNode(true) );
+ } else {
+ main.parentNode.replaceChild(config.fixture.cloneNode(true), main);
}
}
},
return "null";
}
- var type = Object.prototype.toString.call( obj )
- .match(/^\[object\s(.*)\]$/)[1] || '';
+ var type = toString.call( obj ).match(/^\[object\s(.*)\]$/)[1] || '';
switch (type) {
case 'Number':
},
push: function(result, actual, expected, message) {
+ if (!config.current) {
+ throw new Error("assertion outside test context, was " + sourceFromStacktrace());
+ }
var details = {
result: result,
message: message,
expected: expected
};
- message = escapeHtml(message) || (result ? "okay" : "failed");
+ message = escapeInnerText(message) || (result ? "okay" : "failed");
message = '<span class="test-message">' + message + "</span>";
- expected = escapeHtml(QUnit.jsDump.parse(expected));
- actual = escapeHtml(QUnit.jsDump.parse(actual));
- var output = message + '<table><tr class="test-expected"><th>Expected: </th><td><pre>' + expected + '</pre></td></tr>';
- if (actual != expected) {
- output += '<tr class="test-actual"><th>Result: </th><td><pre>' + actual + '</pre></td></tr>';
- output += '<tr class="test-diff"><th>Diff: </th><td><pre>' + QUnit.diff(expected, actual) +'</pre></td></tr>';
- }
+ var output = message;
if (!result) {
+ expected = escapeInnerText(QUnit.jsDump.parse(expected));
+ actual = escapeInnerText(QUnit.jsDump.parse(actual));
+ output += '<table><tr class="test-expected"><th>Expected: </th><td><pre>' + expected + '</pre></td></tr>';
+ if (actual != expected) {
+ output += '<tr class="test-actual"><th>Result: </th><td><pre>' + actual + '</pre></td></tr>';
+ output += '<tr class="test-diff"><th>Diff: </th><td><pre>' + QUnit.diff(expected, actual) +'</pre></td></tr>';
+ }
var source = sourceFromStacktrace();
if (source) {
details.source = source;
- output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeHtml(source) + '</pre></td></tr>';
+ output += '<tr class="test-source"><th>Source: </th><td><pre>' + escapeInnerText(source) + '</pre></td></tr>';
}
+ output += "</table>";
}
- output += "</table>";
- QUnit.log(details);
+ runLoggingCallbacks( 'log', QUnit, details );
config.current.assertions.push({
result: !!result,
var querystring = "?",
key;
for ( key in params ) {
+ if ( !hasOwn.call( params, key ) ) {
+ continue;
+ }
querystring += encodeURIComponent( key ) + "=" +
encodeURIComponent( params[ key ] ) + "&";
}
extend: extend,
id: id,
- addEvent: addEvent,
+ addEvent: addEvent
+});
+//QUnit.constructor is set to the empty F() above so that we can add to it's prototype later
+//Doing this allows us to tell if the following methods have been overwritten on the actual
+//QUnit object, which is a deprecated way of using the callbacks.
+extend(QUnit.constructor.prototype, {
// Logging callbacks; all receive a single argument with the listed properties
// run test/logs.html for any related changes
- begin: function() {},
+ begin: registerLoggingCallback('begin'),
// done: { failed, passed, total, runtime }
- done: function() {},
+ done: registerLoggingCallback('done'),
// log: { result, actual, expected, message }
- log: function() {},
+ log: registerLoggingCallback('log'),
// testStart: { name }
- testStart: function() {},
+ testStart: registerLoggingCallback('testStart'),
// testDone: { name, failed, passed, total }
- testDone: function() {},
+ testDone: registerLoggingCallback('testDone'),
// moduleStart: { name }
- moduleStart: function() {},
+ moduleStart: registerLoggingCallback('moduleStart'),
// moduleDone: { name, failed, passed, total }
- moduleDone: function() {}
+ moduleDone: registerLoggingCallback('moduleDone')
});
if ( typeof document === "undefined" || document.readyState === "complete" ) {
config.autorun = true;
}
-addEvent(window, "load", function() {
- QUnit.begin({});
+QUnit.load = function() {
+ runLoggingCallbacks( 'begin', QUnit, {} );
// Initialize the config, saving the execution queue
var oldconfig = extend({}, config);
config.blocking = false;
+ var urlConfigHtml = '', len = config.urlConfig.length;
+ for ( var i = 0, val; i < len, val = config.urlConfig[i]; i++ ) {
+ config[val] = QUnit.urlParams[val];
+ urlConfigHtml += '<label><input name="' + val + '" type="checkbox"' + ( config[val] ? ' checked="checked"' : '' ) + '>' + val + '</label>';
+ }
+
var userAgent = id("qunit-userAgent");
if ( userAgent ) {
userAgent.innerHTML = navigator.userAgent;
}
var banner = id("qunit-header");
if ( banner ) {
- banner.innerHTML = '<a href="' + QUnit.url({ filter: undefined }) + '"> ' + banner.innerHTML + '</a> ' +
- '<label><input name="noglobals" type="checkbox"' + ( config.noglobals ? ' checked="checked"' : '' ) + '>noglobals</label>' +
- '<label><input name="notrycatch" type="checkbox"' + ( config.notrycatch ? ' checked="checked"' : '' ) + '>notrycatch</label>';
+ banner.innerHTML = '<a href="' + QUnit.url({ filter: undefined }) + '"> ' + banner.innerHTML + '</a> ' + urlConfigHtml;
addEvent( banner, "change", function( event ) {
var params = {};
params[ event.target.name ] = event.target.checked ? true : undefined;
}
if ( defined.sessionStorage ) {
if (filter.checked) {
- sessionStorage.setItem("qunit-filter-passed-tests", "true");
+ sessionStorage.setItem("qunit-filter-passed-tests", "true");
} else {
sessionStorage.removeItem("qunit-filter-passed-tests");
}
}
});
- if ( defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) {
+ if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) {
filter.checked = true;
var ol = document.getElementById("qunit-tests");
ol.className = ol.className + " hidepass";
var main = id('qunit-fixture');
if ( main ) {
- config.fixture = main.innerHTML;
+ config.fixture = main.cloneNode(true);
}
if (config.autostart) {
QUnit.start();
}
-});
+};
+
+addEvent(window, "load", QUnit.load);
+
+// addEvent(window, "error") gives us a useless event object
+window.onerror = function( message, file, line ) {
+ if ( QUnit.config.current ) {
+ ok( false, message + ", " + file + ":" + line );
+ } else {
+ test( "global failure", function() {
+ ok( false, message + ", " + file + ":" + line );
+ });
+ }
+};
function done() {
config.autorun = true;
// Log the last module results
if ( config.currentModule ) {
- QUnit.moduleDone( {
+ runLoggingCallbacks( 'moduleDone', QUnit, {
name: config.currentModule,
failed: config.moduleStats.bad,
passed: config.moduleStats.all - config.moduleStats.bad,
id( "qunit-testresult" ).innerHTML = html;
}
- if ( typeof document !== "undefined" && document.title ) {
- // show ✖ for bad, ✔ for good suite result in title
+ if ( config.altertitle && typeof document !== "undefined" && document.title ) {
+ // show ✖ for good, ✔ for bad suite result in title
// use escape sequences in case file gets loaded with non-utf-8-charset
- document.title = (config.stats.bad ? "\u2716" : "\u2714") + " " + document.title;
+ document.title = [
+ (config.stats.bad ? "\u2716" : "\u2714"),
+ document.title.replace(/^[\u2714\u2716] /i, "")
+ ].join(" ");
+ }
+
+ // clear own sessionStorage items if all tests passed
+ if ( config.reorder && defined.sessionStorage && config.stats.bad === 0 ) {
+ for (var key in sessionStorage) {
+ if (sessionStorage.hasOwnProperty(key) && key.indexOf("qunit-") === 0 ) {
+ sessionStorage.removeItem(key);
+ }
+ }
}
- QUnit.done( {
+ runLoggingCallbacks( 'done', QUnit, {
failed: config.stats.bad,
passed: passed,
total: config.stats.all,
// so far supports only Firefox, Chrome and Opera (buggy)
// could be extended in the future to use something like https://github.com/csnover/TraceKit
-function sourceFromStacktrace() {
+function sourceFromStacktrace(offset) {
+ offset = offset || 3;
try {
throw new Error();
} catch ( e ) {
if (e.stacktrace) {
// Opera
- return e.stacktrace.split("\n")[6];
+ return e.stacktrace.split("\n")[offset + 3];
} else if (e.stack) {
// Firefox, Chrome
- return e.stack.split("\n")[4];
+ var stack = e.stack.split("\n");
+ if (/^error$/i.test(stack[0])) {
+ stack.shift();
+ }
+ return stack[offset];
+ } else if (e.sourceURL) {
+ // Safari, PhantomJS
+ // TODO sourceURL points at the 'throw new Error' line above, useless
+ //return e.sourceURL + ":" + e.line;
}
}
}
-function escapeHtml(s) {
+function escapeInnerText(s) {
if (!s) {
return "";
}
s = s + "";
- return s.replace(/[\&"<>\\]/g, function(s) {
+ return s.replace(/[\&<>]/g, function(s) {
switch(s) {
case "&": return "&";
- case "\\": return "\\\\";
- case '"': return '\"';
case "<": return "<";
case ">": return ">";
default: return s;
});
}
-function synchronize( callback ) {
+function synchronize( callback, last ) {
config.queue.push( callback );
if ( config.autorun && !config.blocking ) {
- process();
+ process(last);
}
}
-function process() {
- var start = (new Date()).getTime();
+function process( last ) {
+ var start = new Date().getTime();
+ config.depth = config.depth ? config.depth + 1 : 1;
while ( config.queue.length && !config.blocking ) {
- if ( config.updateRate <= 0 || (((new Date()).getTime() - start) < config.updateRate) ) {
+ if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) {
config.queue.shift()();
} else {
- window.setTimeout( process, 13 );
+ window.setTimeout( function(){
+ process( last );
+ }, 13 );
break;
}
}
- if (!config.blocking && !config.queue.length) {
- done();
- }
+ config.depth--;
+ if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) {
+ done();
+ }
}
function saveGlobal() {
if ( config.noglobals ) {
for ( var key in window ) {
+ if ( !hasOwn.call( window, key ) ) {
+ continue;
+ }
config.pollution.push( key );
}
}
if ( typeof console !== "undefined" && console.error && console.warn ) {
console.error(message);
console.error(exception);
+ console.error(exception.stack);
console.warn(callback.toString());
} else if ( window.opera && opera.postError ) {
for ( var prop in b ) {
if ( b[prop] === undefined ) {
delete a[prop];
- } else {
+
+ // Avoid "Member not found" error in IE8 caused by setting window.constructor
+ } else if ( prop !== "constructor" || a !== window ) {
a[prop] = b[prop];
}
}
document.getElementById( name );
}
+function registerLoggingCallback(key){
+ return function(callback){
+ config[key].push( callback );
+ };
+}
+
+// Supports deprecated method of completely overwriting logging callbacks
+function runLoggingCallbacks(key, scope, args) {
+ //debugger;
+ var callbacks;
+ if ( QUnit.hasOwnProperty(key) ) {
+ QUnit[key].call(scope, args);
+ } else {
+ callbacks = config[key];
+ for( var i = 0; i < callbacks.length; i++ ) {
+ callbacks[i].call( scope, args );
+ }
+ }
+}
+
// Test for equality any JavaScript type.
-// Discussions and reference: http://philrathe.com/articles/equiv
-// Test suites: http://philrathe.com/tests/equiv
// Author: Philippe Rathé <prathe@gmail.com>
QUnit.equiv = function () {
- var innerEquiv; // the real equiv function
- var callers = []; // stack to decide between skip/abort functions
- var parents = []; // stack to avoiding loops from circular referencing
-
- // Call the o related callback with the given arguments.
- function bindCallbacks(o, callbacks, args) {
- var prop = QUnit.objectType(o);
- if (prop) {
- if (QUnit.objectType(callbacks[prop]) === "function") {
- return callbacks[prop].apply(callbacks, args);
- } else {
- return callbacks[prop]; // or undefined
- }
- }
- }
-
- var callbacks = function () {
-
- // for string, boolean, number and null
- function useStrictEquality(b, a) {
- if (b instanceof a.constructor || a instanceof b.constructor) {
- // to catch short annotaion VS 'new' annotation of a declaration
- // e.g. var i = 1;
- // var j = new Number(1);
- return a == b;
- } else {
- return a === b;
- }
- }
-
- return {
- "string": useStrictEquality,
- "boolean": useStrictEquality,
- "number": useStrictEquality,
- "null": useStrictEquality,
- "undefined": useStrictEquality,
-
- "nan": function (b) {
- return isNaN(b);
- },
-
- "date": function (b, a) {
- return QUnit.objectType(b) === "date" && a.valueOf() === b.valueOf();
- },
-
- "regexp": function (b, a) {
- return QUnit.objectType(b) === "regexp" &&
- a.source === b.source && // the regex itself
- a.global === b.global && // and its modifers (gmi) ...
- a.ignoreCase === b.ignoreCase &&
- a.multiline === b.multiline;
- },
-
- // - skip when the property is a method of an instance (OOP)
- // - abort otherwise,
- // initial === would have catch identical references anyway
- "function": function () {
- var caller = callers[callers.length - 1];
- return caller !== Object &&
- typeof caller !== "undefined";
- },
-
- "array": function (b, a) {
- var i, j, loop;
- var len;
-
- // b could be an object literal here
- if ( ! (QUnit.objectType(b) === "array")) {
- return false;
- }
-
- len = a.length;
- if (len !== b.length) { // safe and faster
- return false;
- }
-
- //track reference to avoid circular references
- parents.push(a);
- for (i = 0; i < len; i++) {
- loop = false;
- for(j=0;j<parents.length;j++){
- if(parents[j] === a[i]){
- loop = true;//dont rewalk array
- }
- }
- if (!loop && ! innerEquiv(a[i], b[i])) {
- parents.pop();
- return false;
- }
- }
- parents.pop();
- return true;
- },
-
- "object": function (b, a) {
- var i, j, loop;
- var eq = true; // unless we can proove it
- var aProperties = [], bProperties = []; // collection of strings
-
- // comparing constructors is more strict than using instanceof
- if ( a.constructor !== b.constructor) {
- return false;
- }
-
- // stack constructor before traversing properties
- callers.push(a.constructor);
- //track reference to avoid circular references
- parents.push(a);
-
- for (i in a) { // be strict: don't ensures hasOwnProperty and go deep
- loop = false;
- for(j=0;j<parents.length;j++){
- if(parents[j] === a[i])
- loop = true; //don't go down the same path twice
- }
- aProperties.push(i); // collect a's properties
-
- if (!loop && ! innerEquiv(a[i], b[i])) {
- eq = false;
- break;
- }
- }
-
- callers.pop(); // unstack, we are done
- parents.pop();
-
- for (i in b) {
- bProperties.push(i); // collect b's properties
- }
-
- // Ensures identical properties name
- return eq && innerEquiv(aProperties.sort(), bProperties.sort());
- }
- };
- }();
-
- innerEquiv = function () { // can take multiple arguments
- var args = Array.prototype.slice.apply(arguments);
- if (args.length < 2) {
- return true; // end transition
- }
-
- return (function (a, b) {
- if (a === b) {
- return true; // catch the most you can
- } else if (a === null || b === null || typeof a === "undefined" || typeof b === "undefined" || QUnit.objectType(a) !== QUnit.objectType(b)) {
- return false; // don't lose time with error prone cases
- } else {
- return bindCallbacks(a, callbacks, [b, a]);
- }
-
- // apply transition with (1..n) arguments
- })(args[0], args[1]) && arguments.callee.apply(this, args.splice(1, args.length -1));
- };
-
- return innerEquiv;
+ var innerEquiv; // the real equiv function
+ var callers = []; // stack to decide between skip/abort functions
+ var parents = []; // stack to avoiding loops from circular referencing
+
+ // Call the o related callback with the given arguments.
+ function bindCallbacks(o, callbacks, args) {
+ var prop = QUnit.objectType(o);
+ if (prop) {
+ if (QUnit.objectType(callbacks[prop]) === "function") {
+ return callbacks[prop].apply(callbacks, args);
+ } else {
+ return callbacks[prop]; // or undefined
+ }
+ }
+ }
+
+ var getProto = Object.getPrototypeOf || function (obj) {
+ return obj.__proto__;
+ };
+
+ var callbacks = function () {
+
+ // for string, boolean, number and null
+ function useStrictEquality(b, a) {
+ if (b instanceof a.constructor || a instanceof b.constructor) {
+ // to catch short annotaion VS 'new' annotation of a
+ // declaration
+ // e.g. var i = 1;
+ // var j = new Number(1);
+ return a == b;
+ } else {
+ return a === b;
+ }
+ }
+
+ return {
+ "string" : useStrictEquality,
+ "boolean" : useStrictEquality,
+ "number" : useStrictEquality,
+ "null" : useStrictEquality,
+ "undefined" : useStrictEquality,
+
+ "nan" : function(b) {
+ return isNaN(b);
+ },
+
+ "date" : function(b, a) {
+ return QUnit.objectType(b) === "date"
+ && a.valueOf() === b.valueOf();
+ },
+
+ "regexp" : function(b, a) {
+ return QUnit.objectType(b) === "regexp"
+ && a.source === b.source && // the regex itself
+ a.global === b.global && // and its modifers
+ // (gmi) ...
+ a.ignoreCase === b.ignoreCase
+ && a.multiline === b.multiline;
+ },
+
+ // - skip when the property is a method of an instance (OOP)
+ // - abort otherwise,
+ // initial === would have catch identical references anyway
+ "function" : function() {
+ var caller = callers[callers.length - 1];
+ return caller !== Object && typeof caller !== "undefined";
+ },
+
+ "array" : function(b, a) {
+ var i, j, loop;
+ var len;
+
+ // b could be an object literal here
+ if (!(QUnit.objectType(b) === "array")) {
+ return false;
+ }
+
+ len = a.length;
+ if (len !== b.length) { // safe and faster
+ return false;
+ }
+
+ // track reference to avoid circular references
+ parents.push(a);
+ for (i = 0; i < len; i++) {
+ loop = false;
+ for (j = 0; j < parents.length; j++) {
+ if (parents[j] === a[i]) {
+ loop = true;// dont rewalk array
+ }
+ }
+ if (!loop && !innerEquiv(a[i], b[i])) {
+ parents.pop();
+ return false;
+ }
+ }
+ parents.pop();
+ return true;
+ },
+
+ "object" : function(b, a) {
+ var i, j, loop;
+ var eq = true; // unless we can proove it
+ var aProperties = [], bProperties = []; // collection of
+ // strings
+
+ // comparing constructors is more strict than using
+ // instanceof
+ if (a.constructor !== b.constructor) {
+ // Allow objects with no prototype to be equivalent to
+ // objects with Object as their constructor.
+ if (!((getProto(a) === null && getProto(b) === Object.prototype) ||
+ (getProto(b) === null && getProto(a) === Object.prototype)))
+ {
+ return false;
+ }
+ }
+
+ // stack constructor before traversing properties
+ callers.push(a.constructor);
+ // track reference to avoid circular references
+ parents.push(a);
+
+ for (i in a) { // be strict: don't ensures hasOwnProperty
+ // and go deep
+ loop = false;
+ for (j = 0; j < parents.length; j++) {
+ if (parents[j] === a[i])
+ loop = true; // don't go down the same path
+ // twice
+ }
+ aProperties.push(i); // collect a's properties
+
+ if (!loop && !innerEquiv(a[i], b[i])) {
+ eq = false;
+ break;
+ }
+ }
+
+ callers.pop(); // unstack, we are done
+ parents.pop();
+
+ for (i in b) {
+ bProperties.push(i); // collect b's properties
+ }
+
+ // Ensures identical properties name
+ return eq
+ && innerEquiv(aProperties.sort(), bProperties
+ .sort());
+ }
+ };
+ }();
+
+ innerEquiv = function() { // can take multiple arguments
+ var args = Array.prototype.slice.apply(arguments);
+ if (args.length < 2) {
+ return true; // end transition
+ }
+
+ return (function(a, b) {
+ if (a === b) {
+ return true; // catch the most you can
+ } else if (a === null || b === null || typeof a === "undefined"
+ || typeof b === "undefined"
+ || QUnit.objectType(a) !== QUnit.objectType(b)) {
+ return false; // don't lose time with error prone cases
+ } else {
+ return bindCallbacks(a, callbacks, [ b, a ]);
+ }
+
+ // apply transition with (1..n) arguments
+ })(args[0], args[1])
+ && arguments.callee.apply(this, args.splice(1,
+ args.length - 1));
+ };
+
+ return innerEquiv;
}();
/**
- * jsDump
- * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
- * Licensed under BSD (http://www.opensource.org/licenses/bsd-license.php)
- * Date: 5/15/2008
+ * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com |
+ * http://flesler.blogspot.com Licensed under BSD
+ * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008
+ *
* @projectDescription Advanced and extensible data dumping for Javascript.
* @version 1.0.0
* @author Ariel Flesler
return pre + post;
return [ pre, inner + arr, base + post ].join(s);
};
- function array( arr ) {
- var i = arr.length, ret = Array(i);
+ function array( arr, stack ) {
+ var i = arr.length, ret = Array(i);
this.up();
while ( i-- )
- ret[i] = this.parse( arr[i] );
+ ret[i] = this.parse( arr[i] , undefined , stack);
this.down();
return join( '[', ret, ']' );
};
var reName = /^function (\w+)/;
var jsDump = {
- parse:function( obj, type ) { //type is used mostly internally, you can fix a (custom)type in advance
- var parser = this.parsers[ type || this.typeOf(obj) ];
+ parse:function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance
+ stack = stack || [ ];
+ var parser = this.parsers[ type || this.typeOf(obj) ];
type = typeof parser;
-
- return type == 'function' ? parser.call( this, obj ) :
- type == 'string' ? parser :
- this.parsers.error;
+ var inStack = inArray(obj, stack);
+ if (inStack != -1) {
+ return 'recursion('+(inStack - stack.length)+')';
+ }
+ //else
+ if (type == 'function') {
+ stack.push(obj);
+ var res = parser.call( this, obj, stack );
+ stack.pop();
+ return res;
+ }
+ // else
+ return (type == 'string') ? parser : this.parsers.error;
},
typeOf:function( obj ) {
var type;
type = "document";
} else if (obj.nodeType) {
type = "node";
- } else if (typeof obj === "object" && typeof obj.length === "number" && obj.length >= 0) {
+ } else if (
+ // native arrays
+ toString.call( obj ) === "[object Array]" ||
+ // NodeList objects
+ ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) )
+ ) {
type = "array";
} else {
type = typeof obj;
array: array,
nodelist: array,
arguments: array,
- object:function( map ) {
+ object:function( map, stack ) {
var ret = [ ];
QUnit.jsDump.up();
- for ( var key in map )
- ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(map[key]) );
+ for ( var key in map ) {
+ var val = map[key];
+ ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(val, undefined, stack));
+ }
QUnit.jsDump.down();
return join( '{', ret, '}' );
},
return ret;
};
+//from jquery.js
+function inArray( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+}
+
/*
* Javascript Diff Algorithm
* By John Resig (http://ejohn.org/)
* QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick <del>brown </del> fox <del>jumped </del><ins>jumps </ins> over"
*/
QUnit.diff = (function() {
- function diff(o, n){
- var ns = new Object();
- var os = new Object();
+ function diff(o, n) {
+ var ns = {};
+ var os = {};
for (var i = 0; i < n.length; i++) {
if (ns[n[i]] == null)
ns[n[i]] = {
- rows: new Array(),
+ rows: [],
o: null
};
ns[n[i]].rows.push(i);
for (var i = 0; i < o.length; i++) {
if (os[o[i]] == null)
os[o[i]] = {
- rows: new Array(),
+ rows: [],
n: null
};
os[o[i]].rows.push(i);
}
for (var i in ns) {
+ if ( !hasOwn.call( ns, i ) ) {
+ continue;
+ }
if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) {
n[ns[i].rows[0]] = {
text: n[ns[i].rows[0]],
};
}
- return function(o, n){
+ return function(o, n) {
o = o.replace(/\s+$/, '');
n = n.replace(/\s+$/, '');
var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/));
};
})();
-})(this);
+// get at whatever the global object is, like window in browsers
+})( (function() {return this}).call() );
element.accordion({
create: function( event, ui ) {
- equals( ui.header.size(), 1, "header size" );
+ equal( ui.header.size(), 1, "header size" );
strictEqual( ui.header[ 0 ], headers[ 0 ], "header" );
- equals( ui.content.size(), 1, "content size" );
+ equal( ui.content.size(), 1, "content size" );
strictEqual( ui.content[ 0 ], contents[ 0 ], "content" );
}
});
element.accordion({
active: 2,
create: function( event, ui ) {
- equals( ui.header.size(), 1, "header size" );
+ equal( ui.header.size(), 1, "header size" );
strictEqual( ui.header[ 0 ], headers[ 2 ], "header" );
- equals( ui.content.size(), 1, "content size" );
+ equal( ui.content.size(), 1, "content size" );
strictEqual( ui.content[ 0 ], contents[ 2 ], "content" );
}
});
active: false,
collapsible: true,
create: function( event, ui ) {
- equals( ui.header.size(), 0, "header size" );
- equals( ui.content.size(), 0, "content size" );
+ equal( ui.header.size(), 0, "header size" );
+ equal( ui.content.size(), 0, "content size" );
}
});
element.accordion( "destroy" );
test("checkbox", function() {
var input = $("#check");
label = $("label[for=check]");
- ok( input.is(":visible") );
+ ok( input.is(":visible") );
ok( label.is(":not(.ui-button)") );
input.button();
ok( input.is(".ui-helper-hidden-accessible") );
test("radios", function() {
var inputs = $("#radio0 input");
labels = $("#radio0 label");
- ok( inputs.is(":visible") );
+ ok( inputs.is(":visible") );
ok( labels.is(":not(.ui-button)") );
inputs.button();
ok( inputs.is(".ui-helper-hidden-accessible") );
test("radio groups", function() {
$(":radio").button();
assert(":eq(0)", ":eq(1)", ":eq(2)");
-
+
// click outside of forms
$("#radio0 .ui-button:eq(1)").click();
assert(":eq(1)", ":eq(1)", ":eq(2)");
-
+
// click in first form
$("#radio1 .ui-button:eq(0)").click();
assert(":eq(1)", ":eq(0)", ":eq(2)");
-
+
// click in second form
$("#radio2 .ui-button:eq(0)").click();
assert(":eq(1)", ":eq(0)", ":eq(0)");
test("input type submit, don't create child elements", function() {
var input = $("#submit")
- same( input.children().length, 0 );
+ deepEqual( input.children().length, 0 );
input.button();
- same( input.children().length, 0 );
+ deepEqual( input.children().length, 0 );
});
test("buttonset", function() {
var set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") );
- same( set.children(".ui-button").length, 3 );
- same( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+ deepEqual( set.children(".ui-button").length, 3 );
+ deepEqual( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
var parent = $("#radio1").parent();
// Set to rtl
parent.attr("dir", "rtl");
-
+
var set = $("#radio1").buttonset();
ok( set.is(".ui-buttonset") );
- same( set.children(".ui-button").length, 3 );
- same( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
+ deepEqual( set.children(".ui-button").length, 3 );
+ deepEqual( set.children("input:radio.ui-helper-hidden-accessible").length, 3 );
ok( set.children("label:eq(0)").is(".ui-button.ui-corner-right:not(.ui-corner-all)") );
ok( set.children("label:eq(1)").is(".ui-button:not(.ui-corner-all)") );
ok( set.children("label:eq(2)").is(".ui-button.ui-corner-left:not(.ui-corner-all)") );
test("disabled, explicit value", function() {
$("#radio01").button({ disabled: false });
- same(false, $("#radio01").button("option", "disabled"),
+ deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
- same(false, $("#radio01").prop("disabled"), "element is disabled");
-
+ deepEqual(false, $("#radio01").prop("disabled"), "element is disabled");
+
$("#radio02").button({ disabled: true });
- same(true, $("#radio02").button("option", "disabled"),
+ deepEqual(true, $("#radio02").button("option", "disabled"),
"disabled option set to true");
- same(true, $("#radio02").prop("disabled"), "element is not disabled");
+ deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled");
});
test("disabled, null", function() {
$("#radio01").button({ disabled: null });
- same(false, $("#radio01").button("option", "disabled"),
+ deepEqual(false, $("#radio01").button("option", "disabled"),
"disabled option set to false");
- same(false, $("#radio01").prop("disabled"), "element is disabled");
-
+ deepEqual(false, $("#radio01").prop("disabled"), "element is disabled");
+
$("#radio02").prop("disabled", true).button({ disabled: null });
- same(true, $("#radio02").button("option", "disabled"),
+ deepEqual(true, $("#radio02").button("option", "disabled"),
"disabled option set to true");
- same(true, $("#radio02").prop("disabled"), "element is not disabled");
+ deepEqual(true, $("#radio02").prop("disabled"), "element is not disabled");
});
test("text false without icon", function() {
text: false
});
ok( $("#button").is(".ui-button-text-only:not(.ui-button-icon-only)") );
-
+
$("#button").button("destroy");
});
}
});
ok( $("#button").is(".ui-button-icon-only:not(.ui-button-text):has(span.ui-icon.iconclass)") );
-
+
$("#button").button("destroy");
});
test("label, default", function() {
$("#button").button();
- same( $("#button").text(), "Label" );
-
+ deepEqual( $("#button").text(), "Label" );
+
$("#button").button("destroy");
});
$("#button").button({
label: "xxx"
});
- same( $("#button").text(), "xxx" );
-
+ deepEqual( $("#button").text(), "xxx" );
+
$("#button").button("destroy");
});
test("label default with input type submit", function() {
- same( $("#submit").button().val(), "Label" );
+ deepEqual( $("#submit").button().val(), "Label" );
});
test("label with input type submit", function() {
var label = $("#submit").button({
label: "xxx"
}).val();
- same( label, "xxx" );
+ deepEqual( label, "xxx" );
});
test("icons", function() {
}
});
ok( $("#button").is(":has(span.ui-icon.ui-button-icon-primary.iconclass):has(span.ui-icon.ui-button-icon-secondary.iconclass2)") );
-
+
$("#button").button("destroy");
});
test('focus - original functionality', function() {
expect(1);
-
+
$('#inputTabindex0')
.focus(function() {
ok(true, 'event triggered');
test('zIndex', function() {
var el = $('#zIndexAutoWithParent'),
parent = el.parent();
- equals(el.zIndex(), 100, 'zIndex traverses up to find value');
- equals(parent.zIndex(200), parent, 'zIndex setter is chainable');
- equals(el.zIndex(), 200, 'zIndex setter changed zIndex');
-
+ equal(el.zIndex(), 100, 'zIndex traverses up to find value');
+ equal(parent.zIndex(200), parent, 'zIndex setter is chainable');
+ equal(el.zIndex(), 200, 'zIndex setter changed zIndex');
+
el = $('#zIndexAutoWithParentViaCSS');
- equals(el.zIndex(), 0, 'zIndex traverses up to find CSS value, not found because not positioned');
-
+ equal(el.zIndex(), 0, 'zIndex traverses up to find CSS value, not found because not positioned');
+
el = $('#zIndexAutoWithParentViaCSSPositioned');
- equals(el.zIndex(), 100, 'zIndex traverses up to find CSS value');
+ equal(el.zIndex(), 100, 'zIndex traverses up to find CSS value');
el.parent().zIndex(200);
- equals(el.zIndex(), 200, 'zIndex setter changed zIndex, overriding CSS');
-
- equals($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
+ equal(el.zIndex(), 200, 'zIndex setter changed zIndex, overriding CSS');
+
+ equal($('#zIndexAutoNoParent').zIndex(), 0, 'zIndex never explicitly set in hierarchy');
});
test( "innerWidth - getter", function() {
var el = $( "#dimensions" );
- equals( el.innerWidth(), 122, "getter passthru" );
+ equal( el.innerWidth(), 122, "getter passthru" );
el.hide();
- equals( el.innerWidth(), 122, "getter passthru when hidden" );
+ equal( el.innerWidth(), 122, "getter passthru when hidden" );
});
test( "innerWidth - setter", function() {
var el = $( "#dimensions" );
el.innerWidth( 120 );
- equals( el.width(), 98, "width set properly" );
+ equal( el.width(), 98, "width set properly" );
el.hide();
el.innerWidth( 100 );
- equals( el.width(), 78, "width set properly when hidden" );
+ equal( el.width(), 78, "width set properly when hidden" );
});
test( "innerHeight - getter", function() {
var el = $( "#dimensions" );
- equals( el.innerHeight(), 70, "getter passthru" );
+ equal( el.innerHeight(), 70, "getter passthru" );
el.hide();
- equals( el.innerHeight(), 70, "getter passthru when hidden" );
+ equal( el.innerHeight(), 70, "getter passthru when hidden" );
});
test( "innerHeight - setter", function() {
var el = $( "#dimensions" );
el.innerHeight( 60 );
- equals( el.height(), 40, "height set properly" );
+ equal( el.height(), 40, "height set properly" );
el.hide();
el.innerHeight( 50 );
- equals( el.height(), 30, "height set properly when hidden" );
+ equal( el.height(), 30, "height set properly when hidden" );
});
test( "outerWidth - getter", function() {
var el = $( "#dimensions" );
- equals( el.outerWidth(), 140, "getter passthru" );
+ equal( el.outerWidth(), 140, "getter passthru" );
el.hide();
- equals( el.outerWidth(), 140, "getter passthru when hidden" );
+ equal( el.outerWidth(), 140, "getter passthru when hidden" );
});
test( "outerWidth - setter", function() {
var el = $( "#dimensions" );
el.outerWidth( 130 );
- equals( el.width(), 90, "width set properly" );
+ equal( el.width(), 90, "width set properly" );
el.hide();
el.outerWidth( 120 );
- equals( el.width(), 80, "width set properly when hidden" );
+ equal( el.width(), 80, "width set properly when hidden" );
});
test( "outerWidth(true) - getter", function() {
var el = $( "#dimensions" );
- equals( el.outerWidth(true), 154, "getter passthru w/ margin" );
+ equal( el.outerWidth(true), 154, "getter passthru w/ margin" );
el.hide();
- equals( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" );
+ equal( el.outerWidth(true), 154, "getter passthru w/ margin when hidden" );
});
test( "outerWidth(true) - setter", function() {
var el = $( "#dimensions" );
el.outerWidth( 130, true );
- equals( el.width(), 76, "width set properly" );
+ equal( el.width(), 76, "width set properly" );
el.hide();
el.outerWidth( 120, true );
- equals( el.width(), 66, "width set properly when hidden" );
+ equal( el.width(), 66, "width set properly when hidden" );
});
test( "outerHeight - getter", function() {
var el = $( "#dimensions" );
- equals( el.outerHeight(), 86, "getter passthru" );
+ equal( el.outerHeight(), 86, "getter passthru" );
el.hide();
- equals( el.outerHeight(), 86, "getter passthru when hidden" );
+ equal( el.outerHeight(), 86, "getter passthru when hidden" );
});
test( "outerHeight - setter", function() {
var el = $( "#dimensions" );
el.outerHeight( 80 );
- equals( el.height(), 44, "height set properly" );
+ equal( el.height(), 44, "height set properly" );
el.hide();
el.outerHeight( 70 );
- equals( el.height(), 34, "height set properly when hidden" );
+ equal( el.height(), 34, "height set properly when hidden" );
});
test( "outerHeight(true) - getter", function() {
var el = $( "#dimensions" );
- equals( el.outerHeight(true), 98, "getter passthru w/ margin" );
+ equal( el.outerHeight(true), 98, "getter passthru w/ margin" );
el.hide();
- equals( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" );
+ equal( el.outerHeight(true), 98, "getter passthru w/ margin when hidden" );
});
test( "outerHeight(true) - setter", function() {
var el = $( "#dimensions" );
el.outerHeight( 90, true );
- equals( el.height(), 42, "height set properly" );
+ equal( el.height(), 42, "height set properly" );
el.hide();
el.outerHeight( 80, true );
- equals( el.height(), 32, "height set properly when hidden" );
+ equal( el.height(), 32, "height set properly when hidden" );
});
})(jQuery);
}
d1 = new Date(d1.getFullYear(), d1.getMonth(), d1.getDate());
d2 = new Date(d2.getFullYear(), d2.getMonth(), d2.getDate());
- equals(d1.toString(), d2.toString(), message);
+ equal(d1.toString(), d2.toString(), message);
}
function equalsDateArray(a1, a2, message) {
a1[1] = (a1[1] ? new Date(a1[1].getFullYear(), a1[1].getMonth(), a1[1].getDate()) : '');
a2[0] = (a2[0] ? new Date(a2[0].getFullYear(), a2[0].getMonth(), a2[0].getDate()) : '');
a2[1] = (a2[1] ? new Date(a2[1].getFullYear(), a2[1].getMonth(), a2[1].getDate()) : '');
- same(a1, a2, message);
+ deepEqual(a1, a2, message);
}
function addMonths(date, offset) {
test("widget method", function() {
var actual = $("#inp").datepicker().datepicker("widget")[0];
- same($("body > #ui-datepicker-div:last-child")[0], actual);
+ deepEqual($("body > #ui-datepicker-div:last-child")[0], actual);
});
test('baseStructure', function() {
ok(dp.is(':visible'), 'Structure - datepicker visible');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure - not right-to-left');
ok(!dp.is('.ui-datepicker-multi'), 'Structure - not multi-month');
- equals(dp.children().length, 2 + (iframe ? 1 : 0), 'Structure - child count');
-
+ equal(dp.children().length, 2 + (iframe ? 1 : 0), 'Structure - child count');
+
var header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure - header division');
- equals(header.children().length, 3, 'Structure - header child count');
+ equal(header.children().length, 3, 'Structure - header child count');
ok(header.children(':first').is('a.ui-datepicker-prev') && header.children(':first').html() != '', 'Structure - prev link');
ok(header.children(':eq(1)').is('a.ui-datepicker-next') && header.children(':eq(1)').html() != '', 'Structure - next link');
-
+
var title = header.children(':last');
ok(title.is('div.ui-datepicker-title') && title.html() != '','Structure - title division');
- equals(title.children().length, 2, 'Structure - title child count');
+ equal(title.children().length, 2, 'Structure - title child count');
ok(title.children(':first').is('span.ui-datepicker-month') && title.children(':first').text() != '', 'Structure - month text')
ok(title.children(':last').is('span.ui-datepicker-year') && title.children(':last').text() != '', 'Structure - year text')
-
+
var table = dp.children(':eq(1)');
ok(table.is('table.ui-datepicker-calendar'), 'Structure - month table');
ok(table.children(':first').is('thead'), 'Structure - month table thead');
var thead = table.children(':first').children(':first');
ok(thead.is('tr'), 'Structure - month table title row');
- equals(thead.find('th').length, 7, 'Structure - month table title cells');
+ equal(thead.find('th').length, 7, 'Structure - month table title cells');
ok(table.children(':eq(1)').is('tbody'), 'Structure - month table body');
ok(table.children(':eq(1)').children('tr').length >= 4, 'Structure - month table week count');
var week = table.children(':eq(1)').children(':first');
ok(week.is('tr'), 'Structure - month table week row');
- equals(week.children().length, 7, 'Structure - week child count');
+ equal(week.children().length, 7, 'Structure - week child count');
ok(week.children(':first').is('td.ui-datepicker-week-end'), 'Structure - month table first day cell');
ok(week.children(':last').is('td.ui-datepicker-week-end'), 'Structure - month table second day cell');
ok(dp.children('iframe').length == (iframe ? 1 : 0), 'Structure - iframe');
inp.datepicker('hide').datepicker('destroy');
-
+
// Editable month/year and button panel
inp = init('#inp', {changeMonth: true, changeYear: true, showButtonPanel: true});
inp.focus();
var title = dp.find('div.ui-datepicker-title');
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure - month selector');
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure - year selector');
-
+
var panel = dp.children(':last');
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure - button panel division');
- equals(panel.children().length, 2, 'Structure - button panel child count');
+ equal(panel.children().length, 2, 'Structure - button panel child count');
ok(panel.children(':first').is('button.ui-datepicker-current'), 'Structure - today button');
ok(panel.children(':last').is('button.ui-datepicker-close'), 'Structure - close button');
inp.datepicker('hide').datepicker('destroy');
-
+
// Multi-month 2
inp = init('#inp', {numberOfMonths: 2});
inp.focus();
ok(dp.is('.ui-datepicker-multi'), 'Structure multi [2] - multi-month');
- equals(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure multi [2] - child count');
+ equal(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure multi [2] - child count');
var child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2] - first month division');
child = dp.children(':eq(1)');
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2] - row break');
ok(dp.is('.ui-datepicker-multi-2'), 'Structure multi [2] - multi-2');
inp.datepicker('hide').datepicker('destroy');
-
+
// Multi-month 3
inp = init('#inp', {numberOfMonths: 3});
inp.focus();
inp = init('#inp', {numberOfMonths: [2, 2]});
inp.focus();
ok(dp.is('.ui-datepicker-multi'), 'Structure multi - multi-month');
- equals(dp.children().length, 6 + (iframe ? 1 : 0), 'Structure multi [2,2] - child count');
+ equal(dp.children().length, 6 + (iframe ? 1 : 0), 'Structure multi [2,2] - child count');
child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure multi [2,2] - first month division');
child = dp.children(':eq(1)');
child = dp.children(':eq(5)');
ok(child.is('div.ui-datepicker-row-break'), 'Structure multi [2,2] - row break');
inp.datepicker('hide').datepicker('destroy');
-
+
// Inline
var inl = init('#inl');
dp = inl.children();
ok(dp.is('.ui-datepicker-inline'), 'Structure inline - main div');
ok(!dp.is('.ui-datepicker-rtl'), 'Structure inline - not right-to-left');
ok(!dp.is('.ui-datepicker-multi'), 'Structure inline - not multi-month');
- equals(dp.children().length, 2, 'Structure inline - child count');
+ equal(dp.children().length, 2, 'Structure inline - child count');
var header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure inline - header division');
- equals(header.children().length, 3, 'Structure inline - header child count');
+ equal(header.children().length, 3, 'Structure inline - header child count');
var table = dp.children(':eq(1)');
ok(table.is('table.ui-datepicker-calendar'), 'Structure inline - month table');
ok(table.children(':first').is('thead'), 'Structure inline - month table thead');
ok(table.children(':eq(1)').is('tbody'), 'Structure inline - month table body');
inl.datepicker('destroy');
-
+
// Inline multi-month
inl = init('#inl', {numberOfMonths: 2});
dp = inl.children();
- ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div');
- equals(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure inline multi - child count');
+ ok(dp.is('.ui-datepicker-inline') && dp.is('.ui-datepicker-multi'), 'Structure inline multi - main div');
+ equal(dp.children().length, 3 + (iframe ? 1 : 0), 'Structure inline multi - child count');
child = dp.children(':first');
ok(child.is('div.ui-datepicker-group') && child.is('div.ui-datepicker-group-first'), 'Structure inline multi - first month division');
child = dp.children(':eq(1)');
ok(dp.is('.ui-datepicker-rtl'), 'Structure RTL - right-to-left');
var header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure RTL - header division');
- equals(header.children().length, 3, 'Structure RTL - header child count');
+ equal(header.children().length, 3, 'Structure RTL - header child count');
ok(header.children(':first').is('a.ui-datepicker-next'), 'Structure RTL - prev link');
- ok(header.children(':eq(1)').is('a.ui-datepicker-prev'), 'Structure RTL - next link');
+ ok(header.children(':eq(1)').is('a.ui-datepicker-prev'), 'Structure RTL - next link');
var panel = dp.children(':last');
ok(panel.is('div.ui-datepicker-buttonpane'), 'Structure RTL - button division');
- equals(panel.children().length, 2, 'Structure RTL - button panel child count');
+ equal(panel.children().length, 2, 'Structure RTL - button panel child count');
ok(panel.children(':first').is('button.ui-datepicker-close'), 'Structure RTL - close button');
ok(panel.children(':last').is('button.ui-datepicker-current'), 'Structure RTL - today button');
inp.datepicker('hide').datepicker('destroy');
inp.val('02/10/2008').focus();
var header = dp.children(':first');
ok(header.is('div.ui-datepicker-header'), 'Structure hide prev/next - header division');
- equals(header.children().length, 1, 'Structure hide prev/next - links child count');
+ equal(header.children().length, 1, 'Structure hide prev/next - links child count');
ok(header.children(':first').is('div.ui-datepicker-title'), 'Structure hide prev/next - title division');
inp.datepicker('hide').datepicker('destroy');
-
+
// Changeable Month with read-only year
inp = init('#inp', {changeMonth: true});
inp.focus();
var title = dp.children(':first').children(':last');
- equals(title.children().length, 2, 'Structure changeable month - title child count');
+ equal(title.children().length, 2, 'Structure changeable month - title child count');
ok(title.children(':first').is('select.ui-datepicker-month'), 'Structure changeable month - month selector');
ok(title.children(':last').is('span.ui-datepicker-year'), 'Structure changeable month - read-only year');
inp.datepicker('hide').datepicker('destroy');
-
+
// Changeable year with read-only month
inp = init('#inp', {changeYear: true});
inp.focus();
var title = dp.children(':first').children(':last');
- equals(title.children().length, 2, 'Structure changeable year - title child count');
+ equal(title.children().length, 2, 'Structure changeable year - title child count');
ok(title.children(':first').is('span.ui-datepicker-month'), 'Structure changeable year - read-only month');
ok(title.children(':last').is('select.ui-datepicker-year'), 'Structure changeable year - year selector');
inp.datepicker('hide').datepicker('destroy');
inp = init('#inp', {changeFirstDay: false});
inp.focus();
var thead = dp.find('.ui-datepicker-calendar thead tr');
- equals(thead.children().length, 7, 'Structure read-only first day - thead child count');
- equals(thead.find('a').length, 0, 'Structure read-only first day - thead links count');
+ equal(thead.children().length, 7, 'Structure read-only first day - thead child count');
+ equal(thead.find('a').length, 0, 'Structure read-only first day - thead links count');
inp.datepicker('hide').datepicker('destroy');
});
inp.val('01/30/2008').datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_PGDN}).
simulate('keydown', {keyCode: $.simulate.VK_ENTER});
- equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),
+ equalsDate(inp.datepicker('getDate'), new Date(2008, 2 - 1, 29),
'Keystroke pgdn - Feb');
inp.val('02/29/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP}).
// onSelect
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_ENTER});
- equals(selectedThis, inp[0], 'Callback selected this');
- equals(selectedInst, $.data(inp[0], PROP_NAME), 'Callback selected inst');
- equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
+ equal(selectedThis, inp[0], 'Callback selected this');
+ equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback selected inst');
+ equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date');
inp.val('').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_DOWN}).
simulate('keydown', {keyCode: $.simulate.VK_ENTER});
date.setDate(date.getDate() + 7);
- equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
+ equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date - ctrl+down');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_ESC});
- equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
+ equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', date),
'Callback selected date - esc');
var dateStr = '02/04/2008';
inp.val(dateStr).datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_ENTER});
- equals(dateStr, selectedDate,
+ equal(dateStr, selectedDate,
'onSelect is called after enter keydown');
// onChangeMonthYear
inp.datepicker('option', {onChangeMonthYear: callback2, onSelect: null}).
date.setDate(1);
inp.simulate('keydown', {keyCode: $.simulate.VK_PGUP});
date.setMonth(date.getMonth() - 1);
- equals(selectedThis, inp[0], 'Callback change month/year this');
- equals(selectedInst, $.data(inp[0], PROP_NAME), 'Callback change month/year inst');
- equals(selectedDate, newMonthYear(date),
+ equal(selectedThis, inp[0], 'Callback change month/year this');
+ equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback change month/year inst');
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year date - pgup');
inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN});
date.setMonth(date.getMonth() + 1);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year date - pgdn');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP});
date.setFullYear(date.getFullYear() - 1);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year date - ctrl+pgup');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_HOME});
date.setFullYear(date.getFullYear() + 1);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year date - ctrl+home');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN});
date.setFullYear(date.getFullYear() + 1);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year date - ctrl+pgdn');
inp.datepicker('setDate', new Date(2007, 1 - 1, 26));
- equals(selectedDate, '2007/1', 'Callback change month/year date - setDate');
+ equal(selectedDate, '2007/1', 'Callback change month/year date - setDate');
selectedDate = null;
inp.datepicker('setDate', new Date(2007, 1 - 1, 12));
ok(selectedDate == null, 'Callback change month/year date - setDate no change');
datepicker('hide').val('').datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_PGUP});
date.setMonth(date.getMonth() - 14);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - pgup');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGUP});
date.setMonth(date.getMonth() - 12);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - ctrl+pgup');
inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN});
date.setMonth(date.getMonth() + 2);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - pgdn');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_PGDN});
date.setMonth(date.getMonth() + 12);
- equals(selectedDate, newMonthYear(date),
+ equal(selectedDate, newMonthYear(date),
'Callback change month/year by 2 date - ctrl+pgdn');
// onClose
inp.datepicker('option', {onClose: callback, onChangeMonthYear: null, stepMonths: 1}).
val('').datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_ESC});
- equals(selectedThis, inp[0], 'Callback close this');
- equals(selectedInst, $.data(inp[0], PROP_NAME), 'Callback close inst');
- equals(selectedDate, '', 'Callback close date - esc');
+ equal(selectedThis, inp[0], 'Callback close this');
+ equal(selectedInst, $.data(inp[0], PROP_NAME), 'Callback close inst');
+ equal(selectedDate, '', 'Callback close date - esc');
inp.val('').datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_ENTER});
- equals(selectedDate, $.datepicker.formatDate('mm/dd/yy', new Date()),
+ equal(selectedDate, $.datepicker.formatDate('mm/dd/yy', new Date()),
'Callback close date - enter');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {keyCode: $.simulate.VK_ESC});
- equals(selectedDate, '02/04/2008', 'Callback close date - preset');
+ equal(selectedDate, '02/04/2008', 'Callback close date - preset');
inp.val('02/04/2008').datepicker('show').
simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});
- equals(selectedDate, '', 'Callback close date - ctrl+end');
+ equal(selectedDate, '', 'Callback close date - ctrl+end');
var inp2 = init('#inp2');
inp2.datepicker().datepicker('option', {onClose: callback}).datepicker('show');
inp.datepicker('show');
- equals(selectedThis, inp2[0], 'Callback close this');
+ equal(selectedThis, inp2[0], 'Callback close this');
});
})(jQuery);
test('setDefaults', function() {
var inp = init('#inp');
- equals($.datepicker._defaults.showOn, 'focus', 'Initial showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Initial showOn');
$.datepicker.setDefaults({showOn: 'button'});
- equals($.datepicker._defaults.showOn, 'button', 'Change default showOn');
+ equal($.datepicker._defaults.showOn, 'button', 'Change default showOn');
$.datepicker.setDefaults({showOn: 'focus'});
- equals($.datepicker._defaults.showOn, 'focus', 'Restore showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Restore showOn');
});
test('option', function() {
var inp = init('#inp');
var inst = $.data(inp[0], PROP_NAME);
// Set option
- equals(inst.settings.showOn, null, 'Initial setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Initial default showOn');
+ equal(inst.settings.showOn, null, 'Initial setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn');
inp.datepicker('option', 'showOn', 'button');
- equals(inst.settings.showOn, 'button', 'Change setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'button', 'Change instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
+ equal(inst.settings.showOn, 'button', 'Change setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'button', 'Change instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
inp.datepicker('option', {showOn: 'both'});
- equals(inst.settings.showOn, 'both', 'Change setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'both', 'Change instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
+ equal(inst.settings.showOn, 'both', 'Change setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'both', 'Change instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
inp.datepicker('option', 'showOn', undefined);
- equals(inst.settings.showOn, null, 'Clear setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
+ equal(inst.settings.showOn, null, 'Clear setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
// Get option
inp = init('#inp');
- equals(inp.datepicker('option', 'showOn'), 'focus', 'Initial setting showOn');
+ equal(inp.datepicker('option', 'showOn'), 'focus', 'Initial setting showOn');
inp.datepicker('option', 'showOn', 'button');
- equals(inp.datepicker('option', 'showOn'), 'button', 'Change instance showOn');
+ equal(inp.datepicker('option', 'showOn'), 'button', 'Change instance showOn');
inp.datepicker('option', 'showOn', undefined);
- equals(inp.datepicker('option', 'showOn'), 'focus', 'Reset instance showOn');
- same(inp.datepicker('option', 'all'), {showAnim: ''}, 'Get instance settings');
- same(inp.datepicker('option', 'defaults'), $.datepicker._defaults,
+ equal(inp.datepicker('option', 'showOn'), 'focus', 'Reset instance showOn');
+ deepEqual(inp.datepicker('option', 'all'), {showAnim: ''}, 'Get instance settings');
+ deepEqual(inp.datepicker('option', 'defaults'), $.datepicker._defaults,
'Get default settings');
});
test('change', function() {
var inp = init('#inp');
var inst = $.data(inp[0], PROP_NAME);
- equals(inst.settings.showOn, null, 'Initial setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Initial default showOn');
+ equal(inst.settings.showOn, null, 'Initial setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'focus', 'Initial instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Initial default showOn');
inp.datepicker('change', 'showOn', 'button');
- equals(inst.settings.showOn, 'button', 'Change setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'button', 'Change instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
+ equal(inst.settings.showOn, 'button', 'Change setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'button', 'Change instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
inp.datepicker('change', {showOn: 'both'});
- equals(inst.settings.showOn, 'both', 'Change setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'both', 'Change instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
+ equal(inst.settings.showOn, 'both', 'Change setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'both', 'Change instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
inp.datepicker('change', 'showOn', undefined);
- equals(inst.settings.showOn, null, 'Clear setting showOn');
- equals($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn');
- equals($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
+ equal(inst.settings.showOn, null, 'Clear setting showOn');
+ equal($.datepicker._get(inst, 'showOn'), 'focus', 'Restore instance showOn');
+ equal($.datepicker._defaults.showOn, 'focus', 'Retain default showOn');
});
test('invocation', function() {
image = inp.siblings('img');
ok(button.length == 1, 'Button - button present');
ok(image.length == 0, 'Button - image absent');
- equals(button.text(), 'Popup', 'Button - button text');
+ equal(button.text(), 'Popup', 'Button - button text');
inp.focus();
ok(!dp.is(':visible'), 'Button - not rendered on focus');
button.click();
ok(button.length == 0, 'Image button - button absent');
image = inp.siblings('img');
ok(image.length == 1, 'Image button - image present');
- equals(image.attr('src'), 'img/calendar.gif', 'Image button - image source');
- equals(image.attr('title'), 'Cal', 'Image button - image text');
+ equal(image.attr('src'), 'img/calendar.gif', 'Image button - image source');
+ equal(image.attr('title'), 'Cal', 'Image button - image text');
inp.focus();
ok(!dp.is(':visible'), 'Image button - not rendered on focus');
image.click();
var inp = init('#inp');
var pop = $('#ui-datepicker-div');
inp.val('06/01/2009').datepicker('show');
- equals(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0',
+ equal(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0',
'Other months - none');
ok(pop.find('td:last *').length == 0, 'Other months - no content');
inp.datepicker('hide').datepicker('option', 'showOtherMonths', true).datepicker('show');
- equals(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234',
+ equal(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234',
'Other months - show');
ok(pop.find('td:last span').length == 1, 'Other months - span content');
inp.datepicker('hide').datepicker('option', 'selectOtherMonths', true).datepicker('show');
- equals(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234',
+ equal(pop.find('tbody').text(), '311234567891011121314151617181920212223242526272829301234',
'Other months - select');
ok(pop.find('td:last a').length == 1, 'Other months - link content');
inp.datepicker('hide').datepicker('option', 'showOtherMonths', false).datepicker('show');
- equals(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0',
+ equal(pop.find('tbody').text(), '\u00a0123456789101112131415161718192021222324252627282930\u00a0\u00a0\u00a0\u00a0',
'Other months - none');
ok(pop.find('td:last *').length == 0, 'Other months - no content');
});
};
var curYear = new Date().getFullYear();
inp.val('02/04/2008').datepicker('show');
- equals(dp.find('.ui-datepicker-year').text(), '2008', 'Year range - read-only default');
+ equal(dp.find('.ui-datepicker-year').text(), '2008', 'Year range - read-only default');
inp.datepicker('hide').datepicker('option', {changeYear: true}).datepicker('show');
- equals(dp.find('.ui-datepicker-year').text(), genRange(2008 - 10, 21), 'Year range - changeable default');
+ equal(dp.find('.ui-datepicker-year').text(), genRange(2008 - 10, 21), 'Year range - changeable default');
inp.datepicker('hide').datepicker('option', {yearRange: 'c-6:c+2', changeYear: true}).datepicker('show');
- equals(dp.find('.ui-datepicker-year').text(), genRange(2008 - 6, 9), 'Year range - c-6:c+2');
+ equal(dp.find('.ui-datepicker-year').text(), genRange(2008 - 6, 9), 'Year range - c-6:c+2');
inp.datepicker('hide').datepicker('option', {yearRange: '2000:2010', changeYear: true}).datepicker('show');
- equals(dp.find('.ui-datepicker-year').text(), genRange(2000, 11), 'Year range - 2000:2010');
+ equal(dp.find('.ui-datepicker-year').text(), genRange(2000, 11), 'Year range - 2000:2010');
inp.datepicker('hide').datepicker('option', {yearRange: '-5:+3', changeYear: true}).datepicker('show');
- equals(dp.find('.ui-datepicker-year').text(), genRange(curYear - 5, 9), 'Year range - -5:+3');
+ equal(dp.find('.ui-datepicker-year').text(), genRange(curYear - 5, 9), 'Year range - -5:+3');
inp.datepicker('hide').datepicker('option', {yearRange: '2000:-5', changeYear: true}).datepicker('show');
- equals(dp.find('.ui-datepicker-year').text(), genRange(2000, curYear - 2004), 'Year range - 2000:-5');
+ equal(dp.find('.ui-datepicker-year').text(), genRange(2000, curYear - 2004), 'Year range - 2000:-5');
inp.datepicker('hide').datepicker('option', {yearRange: '', changeYear: true}).datepicker('show');
- equals(dp.find('.ui-datepicker-year').text(), genRange(curYear, 1), 'Year range - -6:+2');
+ equal(dp.find('.ui-datepicker-year').text(), genRange(curYear, 1), 'Year range - -6:+2');
// Navigation as date format
inp.datepicker('option', {showButtonPanel: true});
- equals(dp.find('.ui-datepicker-prev').text(), 'Prev', 'Navigation prev - default');
- equals(dp.find('.ui-datepicker-current').text(), 'Today', 'Navigation current - default');
- equals(dp.find('.ui-datepicker-next').text(), 'Next', 'Navigation next - default');
+ equal(dp.find('.ui-datepicker-prev').text(), 'Prev', 'Navigation prev - default');
+ equal(dp.find('.ui-datepicker-current').text(), 'Today', 'Navigation current - default');
+ equal(dp.find('.ui-datepicker-next').text(), 'Next', 'Navigation next - default');
inp.datepicker('hide').datepicker('option', {navigationAsDateFormat: true, prevText: '< M', currentText: 'MM', nextText: 'M >'}).
val('02/04/2008').datepicker('show');
var longNames = $.datepicker.regional[''].monthNames;
var shortNames = $.datepicker.regional[''].monthNamesShort;
var date = new Date();
- equals(dp.find('.ui-datepicker-prev').text(), '< ' + shortNames[0], 'Navigation prev - as date format');
- equals(dp.find('.ui-datepicker-current').text(),
+ equal(dp.find('.ui-datepicker-prev').text(), '< ' + shortNames[0], 'Navigation prev - as date format');
+ equal(dp.find('.ui-datepicker-current').text(),
longNames[date.getMonth()], 'Navigation current - as date format');
- equals(dp.find('.ui-datepicker-next').text(),
+ equal(dp.find('.ui-datepicker-next').text(),
shortNames[2] + ' >', 'Navigation next - as date format');
inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN});
- equals(dp.find('.ui-datepicker-prev').text(),
+ equal(dp.find('.ui-datepicker-prev').text(),
'< ' + shortNames[1], 'Navigation prev - as date format + pgdn');
- equals(dp.find('.ui-datepicker-current').text(),
+ equal(dp.find('.ui-datepicker-current').text(),
longNames[date.getMonth()], 'Navigation current - as date format + pgdn');
- equals(dp.find('.ui-datepicker-next').text(),
+ equal(dp.find('.ui-datepicker-next').text(),
shortNames[3] + ' >', 'Navigation next - as date format + pgdn');
inp.datepicker('hide').datepicker('option', {gotoCurrent: true}).
val('02/04/2008').datepicker('show');
- equals(dp.find('.ui-datepicker-prev').text(),
+ equal(dp.find('.ui-datepicker-prev').text(),
'< ' + shortNames[0], 'Navigation prev - as date format + goto current');
- equals(dp.find('.ui-datepicker-current').text(),
+ equal(dp.find('.ui-datepicker-current').text(),
longNames[1], 'Navigation current - as date format + goto current');
- equals(dp.find('.ui-datepicker-next').text(),
+ equal(dp.find('.ui-datepicker-next').text(),
shortNames[2] + ' >', 'Navigation next - as date format + goto current');
});
inp.datepicker('option', {altField: '#alt', altFormat: 'yy-mm-dd'});
date1 = new Date(2008, 6 - 1, 4);
inp.datepicker('setDate', date1);
- equals(inp.val(), '06/04/2008', 'Set date alternate - 06/04/2008');
- equals(alt.val(), '2008-06-04', 'Set date alternate - 2008-06-04');
+ equal(inp.val(), '06/04/2008', 'Set date alternate - 06/04/2008');
+ equal(alt.val(), '2008-06-04', 'Set date alternate - 2008-06-04');
// With minimum/maximum
inp = init('#inp');
date1 = new Date(2008, 1 - 1, 4);
var dateAndTimeToSet = new Date(2008, 3 - 1, 28, 1, 11, 0);
var dateAndTimeClone = new Date(2008, 3 - 1, 28, 1, 11, 0);
inp.datepicker('setDate', dateAndTimeToSet);
- equals(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate');
+ equal(dateAndTimeToSet.getTime(), dateAndTimeClone.getTime(), 'Date object passed should not be changed by setDate');
});
test('altField', function() {
alt.val('');
inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});
- equals(inp.val(), '06/04/2008', 'Alt field - dp - enter');
- equals(alt.val(), '', 'Alt field - alt not set');
+ equal(inp.val(), '06/04/2008', 'Alt field - dp - enter');
+ equal(alt.val(), '', 'Alt field - alt not set');
// Alternate field set
alt.val('');
inp.datepicker('option', {altField: '#alt', altFormat: 'yy-mm-dd'}).
val('06/04/2008').datepicker('show');
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});
- equals(inp.val(), '06/04/2008', 'Alt field - dp - enter');
- equals(alt.val(), '2008-06-04', 'Alt field - alt - enter');
+ equal(inp.val(), '06/04/2008', 'Alt field - dp - enter');
+ equal(alt.val(), '2008-06-04', 'Alt field - alt - enter');
// Move from initial date
alt.val('');
inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).
simulate('keydown', {keyCode: $.simulate.VK_ENTER});
- equals(inp.val(), '07/04/2008', 'Alt field - dp - pgdn');
- equals(alt.val(), '2008-07-04', 'Alt field - alt - pgdn');
+ equal(inp.val(), '07/04/2008', 'Alt field - dp - pgdn');
+ equal(alt.val(), '2008-07-04', 'Alt field - alt - pgdn');
// Alternate field set - closed
alt.val('');
inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {keyCode: $.simulate.VK_PGDN}).
simulate('keydown', {keyCode: $.simulate.VK_ESC});
- equals(inp.val(), '06/04/2008', 'Alt field - dp - pgdn/esc');
- equals(alt.val(), '', 'Alt field - alt - pgdn/esc');
+ equal(inp.val(), '06/04/2008', 'Alt field - dp - pgdn/esc');
+ equal(alt.val(), '', 'Alt field - alt - pgdn/esc');
// Clear date and alternate
alt.val('');
inp.val('06/04/2008').datepicker('show');
inp.simulate('keydown', {ctrlKey: true, keyCode: $.simulate.VK_END});
- equals(inp.val(), '', 'Alt field - dp - ctrl+end');
- equals(alt.val(), '', 'Alt field - alt - ctrl+end');
+ equal(inp.val(), '', 'Alt field - dp - ctrl+end');
+ equal(alt.val(), '', 'Alt field - alt - ctrl+end');
return
// TODO manual entry impl works (see altField demo) but this test doesn't
inp.simulate('keydown', {charCode: '8'.charCodeAt(0)});
inp.simulate('keypress', {charCode: '8'.charCodeAt(0)});
inp.simulate('keyup', {charCode: '8'.charCodeAt(0)});
- equals(inp.val(), '06/04/2008', 'Alt field - dp - manual entry');
- equals(alt.val(), '2008-06-04', 'Alt field - manual entry');
+ equal(inp.val(), '06/04/2008', 'Alt field - dp - manual entry');
+ equal(alt.val(), '2008-06-04', 'Alt field - manual entry');
// Verify alt field is not updated on keyup if date is invalid
inp.val('12/04');
inp.simulate('keydown', {charCode: '/'.charCodeAt(0)});
inp.simulate('keypress', {charCode: '/'.charCodeAt(0)});
inp.simulate('keyup', {charCode: '/'.charCodeAt(0)});
- equals(inp.val(), '12/04/', 'Alt field - dp - manual entry incomplete');
- equals(alt.val(), '2008-06-04', 'Alt field - manual entry - not updated');
+ equal(inp.val(), '12/04/', 'Alt field - dp - manual entry incomplete');
+ equal(alt.val(), '2008-06-04', 'Alt field - manual entry - not updated');
});
test('autoSize', function() {
var inp = init('#inp');
- equals(inp.prop('size'), 20, 'Auto size - default');
+ equal(inp.prop('size'), 20, 'Auto size - default');
inp.datepicker('option', 'autoSize', true);
- equals(inp.prop('size'), 10, 'Auto size - mm/dd/yy');
+ equal(inp.prop('size'), 10, 'Auto size - mm/dd/yy');
inp.datepicker('option', 'dateFormat', 'm/d/yy');
- equals(inp.prop('size'), 10, 'Auto size - m/d/yy');
+ equal(inp.prop('size'), 10, 'Auto size - m/d/yy');
inp.datepicker('option', 'dateFormat', 'D M d yy');
- equals(inp.prop('size'), 15, 'Auto size - D M d yy');
+ equal(inp.prop('size'), 15, 'Auto size - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
- equals(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy');
+ equal(inp.prop('size'), 29, 'Auto size - DD, MM dd, yy');
// French
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['fr']));
- equals(inp.prop('size'), 29, 'Auto size - fr - default');
+ equal(inp.prop('size'), 29, 'Auto size - fr - default');
inp.datepicker('option', 'autoSize', true);
- equals(inp.prop('size'), 10, 'Auto size - fr - dd/mm/yy');
+ equal(inp.prop('size'), 10, 'Auto size - fr - dd/mm/yy');
inp.datepicker('option', 'dateFormat', 'm/d/yy');
- equals(inp.prop('size'), 10, 'Auto size - fr - m/d/yy');
+ equal(inp.prop('size'), 10, 'Auto size - fr - m/d/yy');
inp.datepicker('option', 'dateFormat', 'D M d yy');
- equals(inp.prop('size'), 18, 'Auto size - fr - D M d yy');
+ equal(inp.prop('size'), 18, 'Auto size - fr - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
- equals(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy');
+ equal(inp.prop('size'), 28, 'Auto size - fr - DD, MM dd, yy');
// Hebrew
inp.datepicker('option', $.extend({autoSize: false}, $.datepicker.regional['he']));
- equals(inp.prop('size'), 28, 'Auto size - he - default');
+ equal(inp.prop('size'), 28, 'Auto size - he - default');
inp.datepicker('option', 'autoSize', true);
- equals(inp.prop('size'), 10, 'Auto size - he - dd/mm/yy');
+ equal(inp.prop('size'), 10, 'Auto size - he - dd/mm/yy');
inp.datepicker('option', 'dateFormat', 'm/d/yy');
- equals(inp.prop('size'), 10, 'Auto size - he - m/d/yy');
+ equal(inp.prop('size'), 10, 'Auto size - he - m/d/yy');
inp.datepicker('option', 'dateFormat', 'D M d yy');
- equals(inp.prop('size'), 16, 'Auto size - he - D M d yy');
+ equal(inp.prop('size'), 16, 'Auto size - he - D M d yy');
inp.datepicker('option', 'dateFormat', 'DD, MM dd, yy');
- equals(inp.prop('size'), 23, 'Auto size - he - DD, MM dd, yy');
+ equal(inp.prop('size'), 23, 'Auto size - he - DD, MM dd, yy');
});
test('daylightSaving', function() {
// Australia, Sydney - AM change, southern hemisphere
inp.val('04/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(6) a', dp).simulate('click');
- equals(inp.val(), '04/05/2008', 'Daylight saving - Australia 04/05/2008');
+ equal(inp.val(), '04/05/2008', 'Daylight saving - Australia 04/05/2008');
inp.val('04/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(7) a', dp).simulate('click');
- equals(inp.val(), '04/06/2008', 'Daylight saving - Australia 04/06/2008');
+ equal(inp.val(), '04/06/2008', 'Daylight saving - Australia 04/06/2008');
inp.val('04/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(8) a', dp).simulate('click');
- equals(inp.val(), '04/07/2008', 'Daylight saving - Australia 04/07/2008');
+ equal(inp.val(), '04/07/2008', 'Daylight saving - Australia 04/07/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(6) a', dp).simulate('click');
- equals(inp.val(), '10/04/2008', 'Daylight saving - Australia 10/04/2008');
+ equal(inp.val(), '10/04/2008', 'Daylight saving - Australia 10/04/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(7) a', dp).simulate('click');
- equals(inp.val(), '10/05/2008', 'Daylight saving - Australia 10/05/2008');
+ equal(inp.val(), '10/05/2008', 'Daylight saving - Australia 10/05/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(8) a', dp).simulate('click');
- equals(inp.val(), '10/06/2008', 'Daylight saving - Australia 10/06/2008');
+ equal(inp.val(), '10/06/2008', 'Daylight saving - Australia 10/06/2008');
// Brasil, Brasilia - midnight change, southern hemisphere
inp.val('02/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(20) a', dp).simulate('click');
- equals(inp.val(), '02/16/2008', 'Daylight saving - Brasil 02/16/2008');
+ equal(inp.val(), '02/16/2008', 'Daylight saving - Brasil 02/16/2008');
inp.val('02/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(21) a', dp).simulate('click');
- equals(inp.val(), '02/17/2008', 'Daylight saving - Brasil 02/17/2008');
+ equal(inp.val(), '02/17/2008', 'Daylight saving - Brasil 02/17/2008');
inp.val('02/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(22) a', dp).simulate('click');
- equals(inp.val(), '02/18/2008', 'Daylight saving - Brasil 02/18/2008');
+ equal(inp.val(), '02/18/2008', 'Daylight saving - Brasil 02/18/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(13) a', dp).simulate('click');
- equals(inp.val(), '10/11/2008', 'Daylight saving - Brasil 10/11/2008');
+ equal(inp.val(), '10/11/2008', 'Daylight saving - Brasil 10/11/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(14) a', dp).simulate('click');
- equals(inp.val(), '10/12/2008', 'Daylight saving - Brasil 10/12/2008');
+ equal(inp.val(), '10/12/2008', 'Daylight saving - Brasil 10/12/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(15) a', dp).simulate('click');
- equals(inp.val(), '10/13/2008', 'Daylight saving - Brasil 10/13/2008');
+ equal(inp.val(), '10/13/2008', 'Daylight saving - Brasil 10/13/2008');
// Lebanon, Beirut - midnight change, northern hemisphere
inp.val('03/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(34) a', dp).simulate('click');
- equals(inp.val(), '03/29/2008', 'Daylight saving - Lebanon 03/29/2008');
+ equal(inp.val(), '03/29/2008', 'Daylight saving - Lebanon 03/29/2008');
inp.val('03/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(35) a', dp).simulate('click');
- equals(inp.val(), '03/30/2008', 'Daylight saving - Lebanon 03/30/2008');
+ equal(inp.val(), '03/30/2008', 'Daylight saving - Lebanon 03/30/2008');
inp.val('03/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(36) a', dp).simulate('click');
- equals(inp.val(), '03/31/2008', 'Daylight saving - Lebanon 03/31/2008');
+ equal(inp.val(), '03/31/2008', 'Daylight saving - Lebanon 03/31/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(27) a', dp).simulate('click');
- equals(inp.val(), '10/25/2008', 'Daylight saving - Lebanon 10/25/2008');
+ equal(inp.val(), '10/25/2008', 'Daylight saving - Lebanon 10/25/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(28) a', dp).simulate('click');
- equals(inp.val(), '10/26/2008', 'Daylight saving - Lebanon 10/26/2008');
+ equal(inp.val(), '10/26/2008', 'Daylight saving - Lebanon 10/26/2008');
inp.val('10/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(29) a', dp).simulate('click');
- equals(inp.val(), '10/27/2008', 'Daylight saving - Lebanon 10/27/2008');
+ equal(inp.val(), '10/27/2008', 'Daylight saving - Lebanon 10/27/2008');
// US, Eastern - AM change, northern hemisphere
inp.val('03/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(13) a', dp).simulate('click');
- equals(inp.val(), '03/08/2008', 'Daylight saving - US 03/08/2008');
+ equal(inp.val(), '03/08/2008', 'Daylight saving - US 03/08/2008');
inp.val('03/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(14) a', dp).simulate('click');
- equals(inp.val(), '03/09/2008', 'Daylight saving - US 03/09/2008');
+ equal(inp.val(), '03/09/2008', 'Daylight saving - US 03/09/2008');
inp.val('03/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(15) a', dp).simulate('click');
- equals(inp.val(), '03/10/2008', 'Daylight saving - US 03/10/2008');
+ equal(inp.val(), '03/10/2008', 'Daylight saving - US 03/10/2008');
inp.val('11/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(6) a', dp).simulate('click');
- equals(inp.val(), '11/01/2008', 'Daylight saving - US 11/01/2008');
+ equal(inp.val(), '11/01/2008', 'Daylight saving - US 11/01/2008');
inp.val('11/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(7) a', dp).simulate('click');
- equals(inp.val(), '11/02/2008', 'Daylight saving - US 11/02/2008');
+ equal(inp.val(), '11/02/2008', 'Daylight saving - US 11/02/2008');
inp.val('11/01/2008').datepicker('show');
$('.ui-datepicker-calendar td:eq(8) a', dp).simulate('click');
- equals(inp.val(), '11/03/2008', 'Daylight saving - US 11/03/2008');
+ equal(inp.val(), '11/03/2008', 'Daylight saving - US 11/03/2008');
});
var beforeShowThis = null;
// Before show
var inp = init('#inp', {beforeShow: beforeAll});
var inst = $.data(inp[0], 'datepicker');
- equals($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial');
+ equal($.datepicker._get(inst, 'currentText'), 'Today', 'Before show - initial');
inp.val('02/04/2008').datepicker('show');
- equals($.datepicker._get(inst, 'currentText'), 'Current', 'Before show - changed');
+ equal($.datepicker._get(inst, 'currentText'), 'Current', 'Before show - changed');
ok(beforeShowThis.id == inp[0].id, 'Before show - this OK');
ok(beforeShowInput.id == inp[0].id, 'Before show - input OK');
deepEqual(beforeShowInst, inst, 'Before show - inst OK');
var inp = init('#inp', $.datepicker.regional['fr']);
inp.datepicker('option', {dateFormat: 'DD, d MM yy', showButtonPanel:true, changeMonth:true, changeYear:true}).val('').datepicker('show');
var dp = $('#ui-datepicker-div');
- equals($('.ui-datepicker-close', dp).text(), 'Fermer', 'Localisation - close');
+ equal($('.ui-datepicker-close', dp).text(), 'Fermer', 'Localisation - close');
$('.ui-datepicker-close', dp).simulate('mouseover');
- equals($('.ui-datepicker-prev', dp).text(), 'Précédent', 'Localisation - previous');
- equals($('.ui-datepicker-current', dp).text(), 'Aujourd\'hui', 'Localisation - current');
- equals($('.ui-datepicker-next', dp).text(), 'Suivant', 'Localisation - next');
+ equal($('.ui-datepicker-prev', dp).text(), 'Précédent', 'Localisation - previous');
+ equal($('.ui-datepicker-current', dp).text(), 'Aujourd\'hui', 'Localisation - current');
+ equal($('.ui-datepicker-next', dp).text(), 'Suivant', 'Localisation - next');
var month = 0;
$('.ui-datepicker-month option', dp).each(function() {
- equals($(this).text(), $.datepicker.regional['fr'].monthNamesShort[month],
+ equal($(this).text(), $.datepicker.regional['fr'].monthNamesShort[month],
'Localisation - month ' + month);
month++;
});
var day = 1;
$('.ui-datepicker-calendar th', dp).each(function() {
- equals($(this).text(), $.datepicker.regional['fr'].dayNamesMin[day],
+ equal($(this).text(), $.datepicker.regional['fr'].dayNamesMin[day],
'Localisation - day ' + day);
day = (day + 1) % 7;
});
inp.simulate('keydown', {keyCode: $.simulate.VK_ENTER});
var date = new Date();
- equals(inp.val(), $.datepicker.regional['fr'].dayNames[date.getDay()] + ', ' +
+ equal(inp.val(), $.datepicker.regional['fr'].dayNames[date.getDay()] + ', ' +
date.getDate() + ' ' + $.datepicker.regional['fr'].monthNames[date.getMonth()] +
' ' + date.getFullYear(), 'Localisation - formatting');
});
test('iso8601Week', function() {
var date = new Date(2000, 12 - 1, 31);
- equals($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date);
date = new Date(2001, 1 - 1, 1);
- equals($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
date = new Date(2001, 1 - 1, 7);
- equals($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
date = new Date(2001, 1 - 1, 8);
- equals($.datepicker.iso8601Week(date), 2, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 2, 'ISO 8601 week ' + date);
date = new Date(2003, 12 - 1, 28);
- equals($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 52, 'ISO 8601 week ' + date);
date = new Date(2003, 12 - 1, 29);
- equals($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
date = new Date(2004, 1 - 1, 4);
- equals($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
date = new Date(2004, 1 - 1, 5);
- equals($.datepicker.iso8601Week(date), 2, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 2, 'ISO 8601 week ' + date);
date = new Date(2009, 12 - 1, 28);
- equals($.datepicker.iso8601Week(date), 53, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 53, 'ISO 8601 week ' + date);
date = new Date(2010, 1 - 1, 3);
- equals($.datepicker.iso8601Week(date), 53, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 53, 'ISO 8601 week ' + date);
date = new Date(2010, 1 - 1, 4);
- equals($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
date = new Date(2010, 1 - 1, 10);
- equals($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
+ equal($.datepicker.iso8601Week(date), 1, 'ISO 8601 week ' + date);
});
test('parseDate', function() {
ok(false, 'Parsed error ' + value);
}
catch (e) {
- equals(e, error, 'Parsed error ' + value);
+ equal(e, error, 'Parsed error ' + value);
}
};
expectError(function() { $.datepicker.parseDate(null, 'Sat 2 01'); },
test('formatDate', function() {
init('#inp');
- equals($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)),
+ equal($.datepicker.formatDate('d m y', new Date(2001, 2 - 1, 3)),
'3 2 01', 'Format date d m y');
- equals($.datepicker.formatDate('dd mm yy', new Date(2001, 2 - 1, 3)),
+ equal($.datepicker.formatDate('dd mm yy', new Date(2001, 2 - 1, 3)),
'03 02 2001', 'Format date dd mm yy');
- equals($.datepicker.formatDate('d m y', new Date(2001, 12 - 1, 13)),
+ equal($.datepicker.formatDate('d m y', new Date(2001, 12 - 1, 13)),
'13 12 01', 'Format date d m y');
- equals($.datepicker.formatDate('dd mm yy', new Date(2001, 12 - 1, 13)),
+ equal($.datepicker.formatDate('dd mm yy', new Date(2001, 12 - 1, 13)),
'13 12 2001', 'Format date dd mm yy');
- equals($.datepicker.formatDate('yy-o', new Date(2001, 2 - 1, 3)),
+ equal($.datepicker.formatDate('yy-o', new Date(2001, 2 - 1, 3)),
'2001-34', 'Format date yy-o');
- equals($.datepicker.formatDate('yy-oo', new Date(2001, 2 - 1, 3)),
+ equal($.datepicker.formatDate('yy-oo', new Date(2001, 2 - 1, 3)),
'2001-034', 'Format date yy-oo');
- equals($.datepicker.formatDate('D M y', new Date(2001, 2 - 1, 3)),
+ equal($.datepicker.formatDate('D M y', new Date(2001, 2 - 1, 3)),
'Sat Feb 01', 'Format date D M y');
- equals($.datepicker.formatDate('DD MM yy', new Date(2001, 2 - 1, 3)),
+ equal($.datepicker.formatDate('DD MM yy', new Date(2001, 2 - 1, 3)),
'Saturday February 2001', 'Format date DD MM yy');
- equals($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 2 - 1, 3)),
+ equal($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 2 - 1, 3)),
'Saturday, February 3, 2001', 'Format date DD, MM d, yy');
- equals($.datepicker.formatDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',
+ equal($.datepicker.formatDate('\'day\' d \'of\' MM (\'\'DD\'\'), yy',
new Date(2001, 2 - 1, 3)), 'day 3 of February (\'Saturday\'), 2001',
'Format date \'day\' d \'of\' MM (\'\'DD\'\'), yy');
var gmtDate = new Date(2001, 2 - 1, 3);
gmtDate.setMinutes(gmtDate.getMinutes() - gmtDate.getTimezoneOffset());
- equals($.datepicker.formatDate('@', gmtDate), '981158400000', 'Format date @');
- equals($.datepicker.formatDate('!', gmtDate), '631167552000000000', 'Format date !');
+ equal($.datepicker.formatDate('@', gmtDate), '981158400000', 'Format date @');
+ equal($.datepicker.formatDate('!', gmtDate), '631167552000000000', 'Format date !');
var fr = $.datepicker.regional['fr'];
var settings = {dayNamesShort: fr.dayNamesShort, dayNames: fr.dayNames,
monthNamesShort: fr.monthNamesShort, monthNames: fr.monthNames};
- equals($.datepicker.formatDate('D M y', new Date(2001, 4 - 1, 9), settings),
+ equal($.datepicker.formatDate('D M y', new Date(2001, 4 - 1, 9), settings),
'Lun. Avril 01', 'Format date D M y with settings');
- equals($.datepicker.formatDate('DD MM yy', new Date(2001, 4 - 1, 9), settings),
+ equal($.datepicker.formatDate('DD MM yy', new Date(2001, 4 - 1, 9), settings),
'Lundi Avril 2001', 'Format date DD MM yy with settings');
- equals($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 4 - 1, 9), settings),
+ equal($.datepicker.formatDate('DD, MM d, yy', new Date(2001, 4 - 1, 9), settings),
'Lundi, Avril 9, 2001', 'Format date DD, MM d, yy with settings');
- equals($.datepicker.formatDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy',
+ equal($.datepicker.formatDate('\'jour\' d \'de\' MM (\'\'DD\'\'), yy',
new Date(2001, 4 - 1, 9), settings), 'jour 9 de Avril (\'Lundi\'), 2001',
'Format date \'jour\' d \'de\' MM (\'\'DD\'\'), yy with settings');
});
var dp = $('#ui-datepicker-div');
inp.val('01/01/2010').datepicker('show');
// contains non-breaking space
- equals($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month');
+ equal($('div.ui-datepicker-title').text(), 'January 2010', 'Initial month');
$('a.ui-datepicker-next', dp).click();
$('a.ui-datepicker-next', dp).click();
// contains non-breaking space
- equals($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks');
+ equal($('div.ui-datepicker-title').text(), 'March 2010', 'After next clicks');
inp.datepicker('hide').datepicker('show');
$('a.ui-datepicker-prev', dp).click();
$('a.ui-datepicker-prev', dp).click();
// contains non-breaking space
- equals($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks');
+ equal($('div.ui-datepicker-title').text(), 'November 2009', 'After prev clicks');
inp.datepicker('hide');
});
});
var dp = $('#ui-datepicker-div');
inp.datepicker('show');
- equals(dp.css('display'), 'none',"beforeShow returns false");
+ equal(dp.css('display'), 'none',"beforeShow returns false");
inp.datepicker('destroy');
-
+
inp = init('#inp',{
beforeShow: function(){
}
equal(dp.css('display'), 'block',"beforeShow returns nothing");
inp.datepicker('hide');
inp.datepicker('destroy');
-
+
inp = init('#inp',{
beforeShow: function(){
return true;
});
test('Ticket 6827: formatDate day of year calculation is wrong during day lights savings time', function(){
- var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
- equals(time, "089");
+ var time = $.datepicker.formatDate("oo", new Date("2010/03/30 12:00:00 CDT"));
+ equal(time, "089");
});
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
msg = msg ? msg + "." : "";
var actual = { left: Math.round(offsetAfter.left), top: Math.round(offsetAfter.top) };
var expected = { left: Math.round(offsetBefore.left + dx), top: Math.round(offsetBefore.top + dy) };
- same(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
+ deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
function shouldmove(why) {
msg = msg ? msg + "." : "";
var actual = { width: widthAfter, height: heightAfter };
var expected = { width: widthBefore + dw, height: heightBefore + dh };
- same(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
+ deepEqual(actual, expected, 'resized[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
function shouldresize(why) {
el = $('<div></div>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id');
- equals(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
+ equal(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
el.remove();
el = $('<div></div>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id');
- equals(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
+ equal(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
el.remove();
el = $('<div id="foo">').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id');
- equals(titleId, 'ui-dialog-title-foo', 'carried over title id');
+ equal(titleId, 'ui-dialog-title-foo', 'carried over title id');
el.remove();
});
el = $('<div></div>').dialog();
- equals(dlg().attr('role'), 'dialog', 'dialog role');
+ equal(dlg().attr('role'), 'dialog', 'dialog role');
var labelledBy = dlg().attr('aria-labelledby');
ok(labelledBy.length > 0, 'has aria-labelledby attribute');
- equals(dlg().find('.ui-dialog-title').attr('id'), labelledBy,
+ equal(dlg().find('.ui-dialog-title').attr('id'), labelledBy,
'proper aria-labelledby attribute');
- equals(dlg().find('.ui-dialog-titlebar-close').attr('role'), 'button',
+ equal(dlg().find('.ui-dialog-titlebar-close').attr('role'), 'button',
'close link role');
el.remove();
test("widget method", function() {
var dialog = $("<div>").appendTo("#main").dialog();
- same(dialog.parent()[0], dialog.dialog("widget")[0]);
+ deepEqual(dialog.parent()[0], dialog.dialog("widget")[0]);
});
})(jQuery);
open: function(ev, ui) {
ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
ok(true, 'autoOpen: true fires open callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogopen', 'event type in callback');
- same(ui, {}, 'ui hash in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogopen', 'event type in callback');
+ deepEqual(ui, {}, 'ui hash in callback');
}
});
el.remove();
autoOpen: false,
open: function(ev, ui) {
ok(true, '.dialog("open") fires open callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogopen', 'event type in callback');
- same(ui, {}, 'ui hash in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogopen', 'event type in callback');
+ deepEqual(ui, {}, 'ui hash in callback');
}
}).bind('dialogopen', function(ev, ui) {
ok(el.data("dialog")._isOpen, "interal _isOpen flag is set");
ok(true, 'dialog("open") fires open event');
- equals(this, el[0], 'context of event');
- same(ui, {}, 'ui hash in event');
+ equal(this, el[0], 'context of event');
+ deepEqual(ui, {}, 'ui hash in event');
});
el.dialog("open");
el.remove();
el = $('<div></div>').dialog({
dragStart: function(ev, ui) {
ok(true, 'dragging fires dragStart callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogdragstart', 'event type in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogdragstart', 'event type in callback');
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
}
}).bind('dialogdragstart', function(ev, ui) {
ok(true, 'dragging fires dialogdragstart event');
- equals(this, el[0], 'context of event');
+ equal(this, el[0], 'context of event');
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
test("drag", function() {
expect(9);
var hasDragged = false;
-
+
el = $('<div></div>').dialog({
drag: function(ev, ui) {
if (!hasDragged) {
ok(true, 'dragging fires drag callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogdrag', 'event type in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogdrag', 'event type in callback');
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
-
+
hasDragged = true;
}
}
}).one('dialogdrag', function(ev, ui) {
ok(true, 'dragging fires dialogdrag event');
- equals(this, el[0], 'context of event');
+ equal(this, el[0], 'context of event');
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
el = $('<div></div>').dialog({
dragStop: function(ev, ui) {
ok(true, 'dragging fires dragStop callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogdragstop', 'event type in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogdragstop', 'event type in callback');
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
}
}).bind('dialogdragstop', function(ev, ui) {
ok(true, 'dragging fires dialogdragstop event');
- equals(this, el[0], 'context of event');
+ equal(this, el[0], 'context of event');
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.offset !== undefined, "ui.offset in callback");
});
el = $('<div></div>').dialog({
resizeStart: function(ev, ui) {
ok(true, 'resizing fires resizeStart callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogresizestart', 'event type in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogresizestart', 'event type in callback');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
}
}).bind('dialogresizestart', function(ev, ui) {
ok(true, 'resizing fires dialogresizestart event');
- equals(this, el[0], 'context of event');
+ equal(this, el[0], 'context of event');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
resize: function(ev, ui) {
if (!hasResized) {
ok(true, 'resizing fires resize callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogresize', 'event type in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogresize', 'event type in callback');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
ok(ui.size !== undefined, "ui.size in callback");
-
+
hasResized = true;
}
}
}).one('dialogresize', function(ev, ui) {
ok(true, 'resizing fires dialogresize event');
- equals(this, el[0], 'context of event');
+ equal(this, el[0], 'context of event');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
el = $('<div></div>').dialog({
resizeStop: function(ev, ui) {
ok(true, 'resizing fires resizeStop callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogresizestop', 'event type in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogresizestop', 'event type in callback');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
}
}).bind('dialogresizestop', function(ev, ui) {
ok(true, 'resizing fires dialogresizestop event');
- equals(this, el[0], 'context of event');
+ equal(this, el[0], 'context of event');
ok(ui.originalPosition !== undefined, "ui.originalPosition in callback");
ok(ui.originalSize !== undefined, "ui.originalSize in callback");
ok(ui.position !== undefined, "ui.position in callback");
el = $('<div></div>').dialog({
close: function(ev, ui) {
ok(true, '.dialog("close") fires close callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogclose', 'event type in callback');
- same(ui, {}, 'ui hash in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogclose', 'event type in callback');
+ deepEqual(ui, {}, 'ui hash in callback');
}
}).bind('dialogclose', function(ev, ui) {
ok(true, '.dialog("close") fires dialogclose event');
- equals(this, el[0], 'context of event');
- same(ui, {}, 'ui hash in event');
+ equal(this, el[0], 'context of event');
+ deepEqual(ui, {}, 'ui hash in event');
});
el.dialog('close');
el.remove();
el = $('<div></div>').dialog({
beforeClose: function(ev, ui) {
ok(true, '.dialog("close") fires beforeClose callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogbeforeclose', 'event type in callback');
- same(ui, {}, 'ui hash in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogbeforeclose', 'event type in callback');
+ deepEqual(ui, {}, 'ui hash in callback');
return false;
}
});
el = $('<div></div>').dialog();
el.dialog('option', 'beforeClose', function(ev, ui) {
ok(true, '.dialog("close") fires beforeClose callback');
- equals(this, el[0], "context of callback");
- equals(ev.type, 'dialogbeforeclose', 'event type in callback');
- same(ui, {}, 'ui hash in callback');
+ equal(this, el[0], "context of callback");
+ equal(ev.type, 'dialogbeforeclose', 'event type in callback');
+ deepEqual(ui, {}, 'ui hash in callback');
return false;
});
el.dialog('close');
el = $('<div></div>').dialog().bind('dialogbeforeclose', function(ev, ui) {
ok(true, '.dialog("close") triggers dialogbeforeclose event');
- equals(this, el[0], "context of event");
- same(ui, {}, 'ui hash in event');
+ equal(this, el[0], "context of event");
+ deepEqual(ui, {}, 'ui hash in event');
return false;
});
el.dialog('close');
var expected = $('<div></div>').dialog(),
actual = expected.dialog('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test("enable", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('enable');
- equals(actual, expected, 'enable is chainable');
-
+ equal(actual, expected, 'enable is chainable');
+
el = $('<div></div>').dialog({ disabled: true });
el.dialog('enable');
- equals(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false');
+ equal(el.dialog('option', 'disabled'), false, 'enable method sets disabled option to false');
ok(!dlg().hasClass('ui-dialog-disabled'), 'enable method removes ui-dialog-disabled class from ui-dialog element');
});
test("disable", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('disable');
- equals(actual, expected, 'disable is chainable');
-
+ equal(actual, expected, 'disable is chainable');
+
el = $('<div></div>').dialog({ disabled: false });
el.dialog('disable');
- equals(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true');
+ equal(el.dialog('option', 'disabled'), true, 'disable method sets disabled option to true');
ok(dlg().hasClass('ui-dialog-disabled'), 'disable method adds ui-dialog-disabled class to ui-dialog element');
});
test("close", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('close');
- equals(actual, expected, 'close is chainable');
-
+ equal(actual, expected, 'close is chainable');
+
el = $('<div></div>').dialog();
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog visible before close method called');
el.dialog('close');
expect(4);
el = $('<div></div>').dialog();
- equals(el.dialog('isOpen'), true, "dialog is open after init");
+ equal(el.dialog('isOpen'), true, "dialog is open after init");
el.dialog('close');
- equals(el.dialog('isOpen'), false, "dialog is closed");
+ equal(el.dialog('isOpen'), false, "dialog is closed");
el.remove();
el = $('<div></div>').dialog({autoOpen: false});
- equals(el.dialog('isOpen'), false, "dialog is closed after init");
+ equal(el.dialog('isOpen'), false, "dialog is closed after init");
el.dialog('open');
- equals(el.dialog('isOpen'), true, "dialog is open");
+ equal(el.dialog('isOpen'), true, "dialog is open");
el.remove();
});
test("moveToTop", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('moveToTop');
- equals(actual, expected, 'moveToTop is chainable');
+ equal(actual, expected, 'moveToTop is chainable');
var d1 = $('<div></div>').dialog(), dlg1 = d1.parents('.ui-dialog');
d1.dialog('close');
test("open", function() {
var expected = $('<div></div>').dialog(),
actual = expected.dialog('open');
- equals(actual, expected, 'open is chainable');
+ equal(actual, expected, 'open is chainable');
el = $('<div></div>').dialog({ autoOpen: false });
ok(dlg().is(':hidden') && !dlg().is(':visible'), 'dialog hidden before open method called');
var buttons = {
"Ok": function(ev, ui) {
ok(true, "button click fires callback");
- equals(this, el[0], "context of callback");
- equals(ev.target, btn[0], "event target");
+ equal(this, el[0], "context of callback");
+ equal(ev.target, btn[0], "event target");
},
"Cancel": function(ev, ui) {
ok(true, "button click fires callback");
- equals(this, el[0], "context of callback");
- equals(ev.target, btn[1], "event target");
+ equal(this, el[0], "context of callback");
+ equal(ev.target, btn[1], "event target");
}
};
el = $('<div></div>').dialog({ buttons: buttons });
var btn = $("button", dlg());
- equals(btn.length, 2, "number of buttons");
+ equal(btn.length, 2, "number of buttons");
var i = 0;
$.each(buttons, function(key, val) {
- equals(btn.eq(i).text(), key, "text of button " + (i+1));
+ equal(btn.eq(i).text(), key, "text of button " + (i+1));
i++;
});
ok(btn.parent().hasClass('ui-dialog-buttonset'), "buttons in container");
ok(el.parent().hasClass('ui-dialog-buttons'), "dialog wrapper adds class about having buttons");
-
+
btn.trigger("click");
var newButtons = {
"Close": function(ev, ui) {
ok(true, "button click fires callback");
- equals(this, el[0], "context of callback");
- equals(ev.target, btn[0], "event target");
+ equal(this, el[0], "context of callback");
+ equal(ev.target, btn[0], "event target");
}
};
- same(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter');
+ deepEqual(el.dialog("option", "buttons"), buttons, '.dialog("option", "buttons") getter');
el.dialog("option", "buttons", newButtons);
- same(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');
+ deepEqual(el.dialog("option", "buttons"), newButtons, '.dialog("option", "buttons", ...) setter');
btn = $("button", dlg());
- equals(btn.length, 1, "number of buttons after setter");
+ equal(btn.length, 1, "number of buttons after setter");
btn.trigger('click');
i = 0;
$.each(newButtons, function(key, val) {
- equals(btn.eq(i).text(), key, "text of button " + (i+1));
+ equal(btn.eq(i).text(), key, "text of button " + (i+1));
i += 1;
});
-
+
el.dialog("option", "buttons", null);
btn = $("button", dlg());
- equals(btn.length, 0, "all buttons have been removed");
- equals(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
- equals(el.parent().hasClass('ui-dialog-buttons'), false, "dialog wrapper removes class about having buttons");
+ equal(btn.length, 0, "all buttons have been removed");
+ equal(el.find(".ui-dialog-buttonset").length, 0, "buttonset has been removed");
+ equal(el.parent().hasClass('ui-dialog-buttons'), false, "dialog wrapper removes class about having buttons");
el.remove();
});
"class": "additional-class",
id: "my-button-id",
click: function() {
- equals(this, el[0], "correct context");
+ equal(this, el[0], "correct context");
}
}
]
});
var buttons = dlg().find("button");
- equals(buttons.length, 1, "correct number of buttons");
- equals(buttons.attr("id"), "my-button-id", "correct id");
- equals(buttons.text(), "a button", "correct label");
+ equal(buttons.length, 1, "correct number of buttons");
+ equal(buttons.attr("id"), "my-button-id", "correct id");
+ equal(buttons.text(), "a button", "correct label");
ok(buttons.hasClass("additional-class"), "additional classes added");
buttons.click();
.simulate('keypress', { keyCode: $.ui.keyCode.ESCAPE })
.simulate('keyup', { keyCode: $.ui.keyCode.ESCAPE });
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open after ESC');
-
+
el.remove();
-
+
el = $('<div></div>').dialog({ closeOnEscape: true });
ok(true, 'closeOnEscape: true');
ok(dlg().is(':visible') && !dlg().is(':hidden'), 'dialog is open before ESC');
expect(3);
el = $('<div></div>').dialog();
- equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'close',
+ equal(dlg().find('.ui-dialog-titlebar-close span').text(), 'close',
'default close text');
el.remove();
el = $('<div></div>').dialog({ closeText: "foo" });
- equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'foo',
+ equal(dlg().find('.ui-dialog-titlebar-close span').text(), 'foo',
'closeText on init');
el.remove();
el = $('<div></div>').dialog().dialog('option', 'closeText', 'bar');
- equals(dlg().find('.ui-dialog-titlebar-close span').text(), 'bar',
+ equal(dlg().find('.ui-dialog-titlebar-close span').text(), 'bar',
'closeText via option method');
el.remove();
});
expect(4);
el = $('<div></div>').dialog();
- equals(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
+ equal(dlg().is(".foo"), false, 'dialogClass not specified. foo class added');
el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo" });
- equals(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
+ equal(dlg().is(".foo"), true, 'dialogClass in init. foo class added');
el.remove();
el = $('<div></div>').dialog({ dialogClass: "foo bar" });
- equals(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
- equals(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
+ equal(dlg().is(".foo"), true, 'dialogClass in init, two classes. foo class added');
+ equal(dlg().is(".bar"), true, 'dialogClass in init, two classes. bar class added');
el.remove();
});
expect(4);
el = $('<div></div>').dialog();
- equals(dlg().outerHeight(), 150, "default height");
+ equal(dlg().outerHeight(), 150, "default height");
el.remove();
el = $('<div></div>').dialog({ height: 237 });
- equals(dlg().outerHeight(), 237, "explicit height");
+ equal(dlg().outerHeight(), 237, "explicit height");
el.remove();
el = $('<div></div>').dialog();
el.dialog('option', 'height', 238);
- equals(dlg().outerHeight(), 238, "explicit height set after init");
+ equal(dlg().outerHeight(), 238, "explicit height set after init");
el.remove();
-
+
el = $('<div></div>').css("padding", "20px")
.dialog({ height: 240 });
- equals(dlg().outerHeight(), 240, "explicit height with padding");
+ equal(dlg().outerHeight(), 240, "explicit height with padding");
el.remove();
});
el = $('<div></div>').dialog({ maxHeight: 200 });
drag('.ui-resizable-s', 1000, 1000);
- equals(heightAfter, 200, "maxHeight");
+ equal(heightAfter, 200, "maxHeight");
el.remove();
el = $('<div></div>').dialog({ maxHeight: 200 });
drag('.ui-resizable-n', -1000, -1000);
- equals(heightAfter, 200, "maxHeight");
+ equal(heightAfter, 200, "maxHeight");
el.remove();
el = $('<div></div>').dialog({ maxHeight: 200 }).dialog('option', 'maxHeight', 300);
drag('.ui-resizable-s', 1000, 1000);
- equals(heightAfter, 300, "maxHeight");
+ equal(heightAfter, 300, "maxHeight");
el.remove();
});
el = $('<div></div>').dialog({ maxWidth: 200 });
drag('.ui-resizable-e', 1000, 1000);
- equals(widthAfter, 200, "maxWidth");
+ equal(widthAfter, 200, "maxWidth");
el.remove();
el = $('<div></div>').dialog({ maxWidth: 200 });
drag('.ui-resizable-w', -1000, -1000);
- equals(widthAfter, 200, "maxWidth");
+ equal(widthAfter, 200, "maxWidth");
el.remove();
el = $('<div></div>').dialog({ maxWidth: 200 }).dialog('option', 'maxWidth', 300);
drag('.ui-resizable-w', -1000, -1000);
- equals(widthAfter, 300, "maxWidth");
+ equal(widthAfter, 300, "maxWidth");
el.remove();
});
el = $('<div></div>').dialog({ minHeight: 10 });
drag('.ui-resizable-s', -1000, -1000);
- equals(heightAfter, 10, "minHeight");
+ equal(heightAfter, 10, "minHeight");
el.remove();
el = $('<div></div>').dialog({ minHeight: 10 });
drag('.ui-resizable-n', 1000, 1000);
- equals(heightAfter, 10, "minHeight");
+ equal(heightAfter, 10, "minHeight");
el.remove();
el = $('<div></div>').dialog({ minHeight: 10 }).dialog('option', 'minHeight', 30);
drag('.ui-resizable-n', 1000, 1000);
- equals(heightAfter, 30, "minHeight");
+ equal(heightAfter, 30, "minHeight");
el.remove();
});
el = $('<div></div>').dialog({ minWidth: 10 });
drag('.ui-resizable-e', -1000, -1000);
- equals(widthAfter, 10, "minWidth");
+ equal(widthAfter, 10, "minWidth");
el.remove();
el = $('<div></div>').dialog({ minWidth: 10 });
drag('.ui-resizable-w', 1000, 1000);
- equals(widthAfter, 10, "minWidth");
+ equal(widthAfter, 10, "minWidth");
el.remove();
el = $('<div></div>').dialog({ minWidth: 30 }).dialog('option', 'minWidth', 30);
drag('.ui-resizable-w', 1000, 1000);
- equals(widthAfter, 30, "minWidth");
+ equal(widthAfter, 30, "minWidth");
el.remove();
});
var el = $('<div></div>').dialog();
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
- same(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
+ deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
+ deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
el.remove();
});
var el = $('<div></div>').dialog({ position: "top" });
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
- same(offset.top, $(window).scrollTop());
+ deepEqual(offset.left, Math.round($(window).width() / 2 - dialog.outerWidth() / 2) + $(window).scrollLeft());
+ deepEqual(offset.top, $(window).scrollTop());
el.remove();
});
var el = $('<div></div>').dialog({ position: "left" });
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, 0);
- same(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
+ deepEqual(offset.left, 0);
+ deepEqual(offset.top, Math.round($(window).height() / 2 - dialog.outerHeight() / 2) + $(window).scrollTop());
el.remove();
});
var el = $('<div></div>').dialog({ position: "right bottom" });
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
- same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
+ deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
+ deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
el.remove();
});
var el = $('<div></div>').dialog({ position: ["right", "bottom"] });
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
- same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
+ deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
+ deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
el.remove();
});
var el = $('<div></div>').dialog({ position: [10, 10] });
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, 10 + $(window).scrollLeft());
- same(offset.top, 10 + $(window).scrollTop());
+ deepEqual(offset.left, 10 + $(window).scrollLeft());
+ deepEqual(offset.top, 10 + $(window).scrollTop());
el.remove();
});
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
- same(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
+ deepEqual(offset.left, $(window).width() - dialog.outerWidth() + $(window).scrollLeft());
+ deepEqual(offset.top, $(window).height() - dialog.outerHeight() + $(window).scrollTop());
el.remove();
});
var dialog = el.dialog('widget');
var offset = dialog.offset();
- same(offset.left, 600);
- same(offset.top, 400);
+ deepEqual(offset.left, 600);
+ deepEqual(offset.top, 400);
el.dialog('option', 'position', {
my: "left top",
var offset = dialog.offset();
- same(offset.left, 610);
- same(offset.top, 410);
+ deepEqual(offset.left, 610);
+ deepEqual(offset.top, 410);
el.remove();
parent.remove();
el = $('<div></div>').dialog();
// some browsers return a non-breaking space and some return " "
// so we get the text to normalize to the actual non-breaking space
- equals(dlg().find(".ui-dialog-title").text(), " ", "[default]");
- equals(el.dialog("option", "title"), "", "option not changed");
+ equal(dlg().find(".ui-dialog-title").text(), " ", "[default]");
+ equal(el.dialog("option", "title"), "", "option not changed");
el.remove();
el = $('<div title="foo">').dialog();
- equals(titleText(), "foo", "title in element attribute");
- equals(el.dialog("option", "title"), "foo", "option updated from attribute");
+ equal(titleText(), "foo", "title in element attribute");
+ equal(el.dialog("option", "title"), "foo", "option updated from attribute");
el.remove();
el = $('<div></div>').dialog({ title: 'foo' });
- equals(titleText(), "foo", "title in init options");
- equals(el.dialog("option", "title"), "foo", "opiton set from options hash");
+ equal(titleText(), "foo", "title in init options");
+ equal(el.dialog("option", "title"), "foo", "opiton set from options hash");
el.remove();
el = $('<div title="foo">').dialog({ title: 'bar' });
- equals(titleText(), "bar", "title in init options should override title in element attribute");
- equals(el.dialog("option", "title"), "bar", "opiton set from options hash");
+ equal(titleText(), "bar", "title in init options should override title in element attribute");
+ equal(el.dialog("option", "title"), "bar", "opiton set from options hash");
el.remove();
el = $('<div></div>').dialog().dialog('option', 'title', 'foo');
- equals(titleText(), 'foo', 'title after init');
+ equal(titleText(), 'foo', 'title after init');
el.remove();
});
expect(3);
el = $('<div></div>').dialog();
- equals(dlg().width(), 300, "default width");
+ equal(dlg().width(), 300, "default width");
el.remove();
el = $('<div></div>').dialog({width: 437 });
- equals(dlg().width(), 437, "explicit width");
+ equal(dlg().width(), 437, "explicit width");
el.dialog('option', 'width', 438);
- equals(dlg().width(), 438, 'explicit width after init');
+ equal(dlg().width(), 438, 'explicit width after init');
el.remove();
});
shouldnotresize("[default]");
for (var i=0; i<2; i++) {
el.dialog('close').dialog('open');
- shouldnotresize('initialized with resizable false toggle ('+ (i+1) +')');
+ shouldnotresize('initialized with resizable false toggle ('+ (i+1) +')');
}
el.remove();
shouldresize("[default]");
for (var i=0; i<2; i++) {
el.dialog('close').dialog('option', 'resizable', false).dialog('open');
- shouldnotresize('set option resizable false toggle ('+ (i+1) +')');
+ shouldnotresize('set option resizable false toggle ('+ (i+1) +')');
}
el.remove();
-
+
});
test("#5184: isOpen in dialogclose event is true", function() {
minWidth: 300
});
- equals(el.dialog('option', 'width'), 300, "width is minWidth");
+ equal(el.dialog('option', 'width'), 300, "width is minWidth");
el.dialog('option', 'width', 200);
- equals(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
+ equal(el.dialog('option', 'width'), 300, "width unchanged when set to < minWidth");
el.dialog('option', 'width', 320);
- equals(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
+ equal(el.dialog('option', 'width'), 320, "width changed if set to > minWidth");
el.remove();
el = $('<div></div>').dialog({
expect(2);
d1 = $('<div title="dialog 1">Dialog 1</div>').dialog({modal: true});
d2 = $('<div title="dialog 2">Dialog 2</div>').dialog({modal: true, close: function(){ d2.remove()}});
- equals($.ui.dialog.overlay.instances.length, 2, 'two overlays created');
+ equal($.ui.dialog.overlay.instances.length, 2, 'two overlays created');
d2.dialog('close');
- equals($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay');
+ equal($.ui.dialog.overlay.instances.length, 1, 'one overlay remains after closing the 2nd overlay');
d1.add(d2).remove();
});
msg = msg ? msg + "." : "";
var actual = { left: offsetAfter.left, top: offsetAfter.top };
var expected = { left: offsetBefore.left + dx, top: offsetBefore.top + dy };
- same(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
+ deepEqual(actual, expected, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ' + msg);
}
function restoreScroll(what) {
drag(el, 10, 10);
- equals(start, 1, "start callback should happen exactly once");
- equals(dragc, 3, "drag callback should happen exactly once per mousemove");
- equals(stop, 1, "stop callback should happen exactly once");
+ equal(start, 1, "start callback should happen exactly once");
+ equal(dragc, 3, "drag callback should happen exactly once per mousemove");
+ equal(stop, 1, "stop callback should happen exactly once");
});
drag(el, 10, 10);
- equals(start, 1, "start callback should happen exactly once");
- equals(dragc, 0, "drag callback should not happen at all");
- equals(stop, 0, "stop callback should not happen if there wasnt even a start");
+ equal(start, 1, "start callback should happen exactly once");
+ equal(dragc, 0, "drag callback should not happen at all");
+ equal(stop, 0, "stop callback should not happen if there wasnt even a start");
});
drag(el, 10, 10);
- equals(start, 1, "start callback should happen exactly once");
- equals(dragc, 1, "drag callback should happen exactly once");
- equals(stop, 1, "stop callback should happen, as we need to actively stop the drag");
+ equal(start, 1, "start callback should happen exactly once");
+ equal(dragc, 1, "drag callback should happen exactly once");
+ equal(stop, 1, "stop callback should happen, as we need to actively stop the drag");
});
var expected = $('<div></div>').draggable(),
actual = expected.draggable('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test("enable", function() {
shouldnotmove('.draggable({ disabled: true })');
el.draggable("enable");
shouldmove('.draggable("enable")');
- equals(el.draggable("option", "disabled"), false, "disabled option getter");
+ equal(el.draggable("option", "disabled"), false, "disabled option getter");
el.draggable("destroy");
el.draggable({ disabled: true });
shouldnotmove('.draggable({ disabled: true })');
el.draggable("option", "disabled", false);
- equals(el.draggable("option", "disabled"), false, "disabled option setter");
+ equal(el.draggable("option", "disabled"), false, "disabled option setter");
shouldmove('.draggable("option", "disabled", false)');
-
+
var expected = $('<div></div>').draggable(),
actual = expected.draggable('enable');
- equals(actual, expected, 'enable is chainable');
+ equal(actual, expected, 'enable is chainable');
});
test("disable", function() {
shouldmove('.draggable({ disabled: false })');
el.draggable("disable");
shouldnotmove('.draggable("disable")');
- equals(el.draggable("option", "disabled"), true, "disabled option getter");
+ equal(el.draggable("option", "disabled"), true, "disabled option getter");
el.draggable("destroy");
el.draggable({ disabled: false });
shouldmove('.draggable({ disabled: false })');
el.draggable("option", "disabled", true);
- equals(el.draggable("option", "disabled"), true, "disabled option setter");
+ equal(el.draggable("option", "disabled"), true, "disabled option setter");
shouldnotmove('.draggable("option", "disabled", true)');
-
+
var expected = $('<div></div>').draggable(),
actual = expected.draggable('disable');
- equals(actual, expected, 'disable is chainable');
+ equal(actual, expected, 'disable is chainable');
});
})(jQuery);
module("draggable: options");
test("{ addClasses: true }, default", function() {
- equals(draggable_defaults.addClasses, true);
+ equal(draggable_defaults.addClasses, true);
el = $("<div></div>").draggable({ addClasses: true });
ok(el.is(".ui-draggable"), "'ui-draggable' class added");
});
test("{ appendTo: 'parent' }, default", function() {
- equals(draggable_defaults.appendTo, "parent");
+ equal(draggable_defaults.appendTo, "parent");
el = $("#draggable2").draggable({ appendTo: 'parent' });
drag(el, 50, 50);
moved(50, 50);
-
+
el = $("#draggable1").draggable({ appendTo: 'parent' });
drag(el, 50, 50);
moved(50, 50);
el = $("#draggable2").draggable({ appendTo: $("#draggable2").parent()[0] });
drag(el, 50, 50);
moved(50, 50);
-
+
el = $("#draggable1").draggable({ appendTo: $("#draggable2").parent()[0] });
drag(el, 50, 50);
moved(50, 50);
el = $("#draggable2").draggable({ appendTo: "#main" });
drag(el, 50, 50);
moved(50, 50);
-
+
el = $("#draggable1").draggable({ appendTo: "#main" });
drag(el, 50, 50);
moved(50, 50);
});
test("{ axis: false }, default", function() {
- equals(draggable_defaults.axis, false);
+ equal(draggable_defaults.axis, false);
el = $("#draggable2").draggable({ axis: false });
drag(el, 50, 50);
});
test("{ cancel: ':input,option' }, default", function() {
- equals(draggable_defaults.cancel, ":input,option");
+ equal(draggable_defaults.cancel, ":input,option");
$('<div id="draggable-option-cancel-default"><input type="text"></div>').appendTo('#main');
});
test("{ containment: false }, default", function() {
- equals(draggable_defaults.containment, false);
+ equal(draggable_defaults.containment, false);
ok(false, 'missing test - untested code is broken code');
});
left: po.left + border(p, 'left') + margin(el, 'left'),
top: po.top + border(p, 'top') + margin(el, 'top')
}
- same(offsetAfter, expected, 'compare offset to parent');
+ deepEqual(offsetAfter, expected, 'compare offset to parent');
});
test("{ containment: 'parent' }, absolute", function() {
left: po.left + border(p, 'left') + margin(el, 'left'),
top: po.top + border(p, 'top') + margin(el, 'top')
}
- same(offsetAfter, expected, 'compare offset to parent');
+ deepEqual(offsetAfter, expected, 'compare offset to parent');
});
test("{ containment: 'document' }", function() {
});
test("{ cursor: 'auto' }, default", function() {
- equals(draggable_defaults.cursor, 'auto');
+ equal(draggable_defaults.cursor, 'auto');
function getCursor() { return $("#draggable2").css("cursor"); }
drag("#draggable2", -1, -1);
after = getCursor();
- equals(actual, expected, "start callback: cursor '" + expected + "'");
- equals(after, before, "after drag: cursor restored");
+ equal(actual, expected, "start callback: cursor '" + expected + "'");
+ equal(after, before, "after drag: cursor restored");
});
drag("#draggable2", -1, -1);
after = getCursor();
- equals(actual, expected, "start callback: cursor '" + expected + "'");
- equals(after, before, "after drag: cursor restored");
+ equal(actual, expected, "start callback: cursor '" + expected + "'");
+ equal(after, before, "after drag: cursor restored");
});
test("{ cursorAt: false}, default", function() {
- equals(draggable_defaults.cursorAt, false);
+ equal(draggable_defaults.cursorAt, false);
ok(false, 'missing test - untested code is broken code');
});
var el = $('#draggable' + (i + 1)).draggable({
cursorAt: { left: cursorAtX, top: cursorAtY },
drag: function(event, ui) {
- equals(ui.offset.left, expected.left, position + ' left');
- equals(ui.offset.top, expected.top, position + ' top');
+ equal(ui.offset.left, expected.left, position + ' left');
+ equal(ui.offset.top, expected.top, position + ' top');
}
}),
before = el.offset(),
var el = $('#draggable' + (i + 1)).draggable({
cursorAt: { right: cursorAtX, bottom: cursorAtY },
drag: function(event, ui) {
- equals(ui.offset.left, expected.left, position + ' left');
- equals(ui.offset.top, expected.top, position + ' top');
+ equal(ui.offset.left, expected.left, position + ' left');
+ equal(ui.offset.top, expected.top, position + ' top');
}
}),
before = el.offset(),
var el = $('#draggable' + (i + 1)).draggable({
cursorAt: { left: cursorAtX, top: cursorAtY },
drag: function(event, ui) {
- equals(ui.offset.left, expected.left, position + ' left');
- equals(ui.offset.top, expected.top, position + ' top');
+ equal(ui.offset.left, expected.left, position + ' left');
+ equal(ui.offset.top, expected.top, position + ' top');
}
}),
before = el.offset(),
var el = $('#draggable' + (i + 1)).draggable({
cursorAt: { left: cursorAtX, top: cursorAtY },
drag: function(event, ui) {
- equals(ui.offset.left, expected.left, position + ' left');
- equals(ui.offset.top, expected.top, position + ' top');
+ equal(ui.offset.left, expected.left, position + ' left');
+ equal(ui.offset.top, expected.top, position + ' top');
}
}),
before = el.offset(),
});
test("{ helper: 'original' }, relative, with scroll offset on parent", function() {
-
+
el = $("#draggable1").draggable({ helper: "original" });
setScroll();
testScroll('relative');
-
+
setScroll();
testScroll('static');
-
+
setScroll();
testScroll('absolute');
restoreScroll();
-
+
});
test("{ helper: 'original' }, relative, with scroll offset on root", function() {
-
+
el = $("#draggable1").draggable({ helper: "original" });
-
+
setScroll('root');
testScroll('relative');
-
+
setScroll('root');
testScroll('static');
-
+
setScroll('root');
testScroll('absolute');
restoreScroll('root');
-
+
});
test("{ helper: 'original' }, relative, with scroll offset on root and parent", function() {
-
+
el = $("#draggable1").draggable({ helper: "original" });
-
+
setScroll();
setScroll('root');
testScroll('relative');
-
+
setScroll();
setScroll('root');
testScroll('static');
-
+
setScroll();
setScroll('root');
testScroll('absolute');
restoreScroll();
restoreScroll('root');
-
+
});
test("{ helper: 'original' }, absolute, with scroll offset on parent", function() {
setScroll();
testScroll('relative');
-
+
setScroll();
testScroll('static');
-
+
setScroll();
testScroll('absolute');
test("{ helper: 'original' }, absolute, with scroll offset on root", function() {
el = $("#draggable1").css({ position: 'absolute', top: 0, left: 0 }).draggable({ helper: "original" });
-
+
setScroll('root');
testScroll('relative');
-
+
setScroll('root');
testScroll('static');
-
+
setScroll('root');
testScroll('absolute');
restoreScroll('root');
-
+
});
test("{ helper: 'original' }, absolute, with scroll offset on root and parent", function() {
setScroll();
setScroll('root');
testScroll('relative');
-
+
setScroll();
setScroll('root');
testScroll('static');
-
+
setScroll();
setScroll('root');
testScroll('absolute');
restoreScroll();
restoreScroll('root');
-
+
});
test("{ helper: 'original' }, fixed, with scroll offset on parent", function() {
setScroll();
testScroll('relative');
-
+
setScroll();
testScroll('static');
-
+
setScroll();
testScroll('absolute');
});
test("{ helper: 'original' }, fixed, with scroll offset on root", function() {
-
+
el = $("#draggable1").css({ position: 'fixed', top: 0, left: 0 }).draggable({ helper: "original" });
setScroll('root');
testScroll('relative');
-
+
setScroll('root');
testScroll('static');
-
+
setScroll('root');
testScroll('absolute');
setScroll();
setScroll('root');
testScroll('relative');
-
+
setScroll();
setScroll('root');
testScroll('static');
-
+
setScroll();
setScroll('root');
testScroll('absolute');
-
+
restoreScroll();
restoreScroll('root');
} });
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
});
$("#main").css('position', 'relative');
origOffset = $("#draggable1").offset();
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$("#main").css('position', 'static');
origOffset = $("#draggable1").offset();
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
-
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
$("#main").css('position', 'absolute');
origOffset = $("#draggable1").offset();
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
-
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
restoreScroll();
});
el = $("#draggable1").draggable({ helper: "clone", drag: function(event, ui) {
helperOffset = ui.helper.offset();
} });
-
+
$("#main").css('position', 'relative');
origOffset = $("#draggable1").offset();
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$("#main").css('position', 'static');
origOffset = $("#draggable1").offset();
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
-
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
$("#main").css('position', 'absolute');
origOffset = $("#draggable1").offset();
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
-
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
restoreScroll('root');
});
$("#main").css('position', 'relative');
origOffset = $("#draggable1").offset()
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
$("#main").css('position', 'static');
origOffset = $("#draggable1").offset()
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
-
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
$("#main").css('position', 'absolute');
origOffset = $("#draggable1").offset()
drag(el, 1, 1);
- same({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
-
+ deepEqual({ top: helperOffset.top-1, left: helperOffset.left-1 }, origOffset, 'dragged[' + dragged.dx + ', ' + dragged.dy + '] ');
+
restoreScroll('root');
restoreScroll();
drag("#draggable2", -1, -1);
- equals(opacity, 0.5, "start callback: opacity is");
+ equal(opacity, 0.5, "start callback: opacity is");
});
drag("#draggable2", -1, -1);
- equals(actual, expected, "start callback: zIndex is");
+ equal(actual, expected, "start callback: zIndex is");
});
$("<div></div>").droppable().droppable("destroy").droppable("foo");
ok(true, 'arbitrary method called after destroy');
-
+
var expected = $('<div></div>').droppable(),
actual = expected.droppable('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test("enable", function() {
shouldNotBeDroppable();
el.droppable("enable");
shouldBeDroppable();
- equals(el.droppable("option", "disabled"), false, "disabled option getter");
+ equal(el.droppable("option", "disabled"), false, "disabled option getter");
el.droppable("destroy");
el.droppable({ disabled: true });
shouldNotBeDroppable();
el.droppable("option", "disabled", false);
- equals(el.droppable("option", "disabled"), false, "disabled option setter");
+ equal(el.droppable("option", "disabled"), false, "disabled option setter");
shouldBeDroppable();
-
+
var expected = $('<div></div>').droppable(),
actual = expected.droppable('enable');
- equals(actual, expected, 'enable is chainable');
+ equal(actual, expected, 'enable is chainable');
});
test("disable", function() {
shouldBeDroppable();
el.droppable("disable");
shouldNotBeDroppable();
- equals(el.droppable("option", "disabled"), true, "disabled option getter");
+ equal(el.droppable("option", "disabled"), true, "disabled option getter");
el.droppable("destroy");
el.droppable({ disabled: false });
shouldBeDroppable();
el.droppable("option", "disabled", true);
- equals(el.droppable("option", "disabled"), true, "disabled option setter");
+ equal(el.droppable("option", "disabled"), true, "disabled option setter");
shouldNotBeDroppable();
-
+
var expected = $('<div></div>').droppable(),
actual = expected.droppable('disable');
- equals(actual, expected, 'disable is chainable');
+ equal(actual, expected, 'disable is chainable');
});
})(jQuery);
module("droppable: options");
test("{ accept '*' }, default ", function() {
- equals(droppable_defaults.accept, '*');
+ equal(droppable_defaults.accept, '*');
ok(false, 'missing test - untested code is broken code');
});
});
test("{ addClasses: true }, default", function() {
- equals(droppable_defaults.addClasses, true);
+ equal(droppable_defaults.addClasses, true);
el = $("<div></div>").droppable({ addClasses: true });
ok(el.is(".ui-droppable"), "'ui-droppable' class added");
var item0 = $("li:eq(0) a");
ok( menu.hasClass("ui-menu ui-widget ui-widget-content ui-corner-all"), "menu class");
- equals( menu.attr("role"), "menu", "main role");
+ equal( menu.attr("role"), "menu", "main role");
ok( !menu.attr("aria-activedescendant"), "aria attribute not yet active");
var item = menu.find( "li:first" ).find( "a" ).attr( "id", "xid" ).end();
menu.menu( "focus", $.Event(), item );
- equals( menu.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
+ equal( menu.attr("aria-activedescendant"), "xid", "aria attribute, id from dom");
var item = menu.find( "li:last" );
menu.menu( "focus", $.Event(), item );
- equals( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
+ equal( menu.attr("aria-activedescendant"), "menu1-4", "aria attribute, generated id");
});
test("items class and role", function () {
ok( ($("li",menu).length > 0 ), "number of menu items");
$("li",menu).each(function(item) {
ok( $(this).hasClass("ui-menu-item"), "menu item ("+ item + ") class for item");
- equals( $(this).attr("role"), "presentation", "menu item ("+ item + ") role");
- equals( $("a", this).attr("role"), "menuitem", "menu item ("+ item + ") role");
+ equal( $(this).attr("role"), "presentation", "menu item ("+ item + ") role");
+ equal( $("a", this).attr("role"), "menuitem", "menu item ("+ item + ") role");
ok( $("a",this).hasClass("ui-corner-all"), "a element class for menu item ("+ item + ") ");
- equals( $("a",this).attr("tabindex"), "-1", "a element tabindex for menu item ("+ item + ") ");
+ equal( $("a",this).attr("tabindex"), "-1", "a element tabindex for menu item ("+ item + ") ");
});
});
menu_click( menu,"2");
menu_click($('#menu1'),"3");
menu_click( menu,"1");
- equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
+ equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
test("handle click on custom item menu", function() {
menu_click( menu,"2");
menu_click($('#menu5'),"3");
menu_click( menu,"1");
- equals( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
+ equal( $("#log").html(), "1,3,2,afterclick,1,click,", "Click order not valid.");
});
-/* Commenting out these tests until a way to handle the extra focus and blur events
+/* Commenting out these tests until a way to handle the extra focus and blur events
fired by IE is found
test( "handle blur: click", function() {
expect( 4 );
element.focus();
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equals( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
+ equal( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equals( $("#log").html(), "1,keydown,", "Keydown UP");
+ equal( $("#log").html(), "1,keydown,", "Keydown UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN");
+ equal( $("#log").html(), "4,keydown,", "Keydown PAGE_DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+ equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
- equals( $("#log").html(), "4,keydown,", "Keydown END");
+ equal( $("#log").html(), "4,keydown,", "Keydown END");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
- equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+ equal( $("#log").html(), "0,keydown,", "Keydown HOME");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
+ equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
});
asyncTest("handle keyboard navigation on menu without scroll and with submenus", function() {
element.one( "menufocus", function( event, ui ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equals( $("#log").html(), "2,1,keydown,", "Keydown DOWN");
+ equal( $("#log").html(), "2,1,keydown,", "Keydown DOWN");
setTimeout( menukeyboard1, 50 );
});
element.focus();
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equals( $("#log").html(), "0,1,keydown,", "Keydown UP");
+ equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( function() {
- equals( $("#log").html(), "0,4,3,2,1,keydown,", "Keydown RIGHT (open submenu)");
+ equal( $("#log").html(), "0,4,3,2,1,keydown,", "Keydown RIGHT (open submenu)");
}, 50);
setTimeout( menukeyboard2, 50 );
}
function menukeyboard2() {
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equals( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)");
+ equal( $("#log").html(), "4,keydown,", "Keydown LEFT (close submenu)");
//re-open submenu
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
function menukeyboard3() {
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN");
+ equal( $("#log").html(), "2,keydown,", "Keydown PAGE_DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+ equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
- equals( $("#log").html(), "2,keydown,", "Keydown END");
+ equal( $("#log").html(), "2,keydown,", "Keydown END");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
- equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+ equal( $("#log").html(), "0,keydown,", "Keydown HOME");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equals( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)");
+ equal( $("#log").html(), "4,keydown,", "Keydown ESCAPE (close submenu)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
}
function menukeyboard4() {
- equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
+ equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equals( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)");
+ equal( $("#log").html(), "Ada,keydown,", "Keydown ENTER (select item)");
start();
}
element.focus();
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equals( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
+ equal( $("#log").html(), "2,1,0,keydown,", "Keydown DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equals( $("#log").html(), "0,1,keydown,", "Keydown UP");
+ equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
- equals( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
+ equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
+ equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
+ equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+ equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown PAGE_UP (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
- equals( $("#log").html(), "37,keydown,", "Keydown END");
+ equal( $("#log").html(), "37,keydown,", "Keydown END");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown PAGE_DOWN (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
- equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+ equal( $("#log").html(), "0,keydown,", "Keydown HOME");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equals( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown ESCAPE (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
+ equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER");
});
asyncTest("handle keyboard navigation on menu with scroll and with submenus", function() {
element.one( "menufocus", function( event, ui ) {
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- equals( $("#log").html(), "2,1,keydown,", "Keydown DOWN");
+ equal( $("#log").html(), "2,1,keydown,", "Keydown DOWN");
setTimeout( menukeyboard1, 50 );
});
element.focus();
-
+
function menukeyboard1() {
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
- equals( $("#log").html(), "0,1,keydown,", "Keydown UP");
+ equal( $("#log").html(), "0,1,keydown,", "Keydown UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equals( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+ equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
setTimeout( function() {
- equals( $("#log").html(), "0,1,keydown,", "Keydown RIGHT (open submenu)");
+ equal( $("#log").html(), "0,1,keydown,", "Keydown RIGHT (open submenu)");
}, 50);
setTimeout( menukeyboard2, 50 );
}
function menukeyboard2() {
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
- equals( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)");
+ equal( $("#log").html(), "1,keydown,", "Keydown LEFT (close submenu)");
//re-open submenu
element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
function menukeyboard3() {
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
+ equal( $("#log").html(), "10,keydown,", "Keydown PAGE_DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_DOWN } );
- equals( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
+ equal( $("#log").html(), "20,keydown,", "Keydown PAGE_DOWN");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
+ equal( $("#log").html(), "10,keydown,", "Keydown PAGE_UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.PAGE_UP } );
- equals( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
+ equal( $("#log").html(), "0,keydown,", "Keydown PAGE_UP");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.END } );
- equals( $("#log").html(), "27,keydown,", "Keydown END");
+ equal( $("#log").html(), "27,keydown,", "Keydown END");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.HOME } );
- equals( $("#log").html(), "0,keydown,", "Keydown HOME");
+ equal( $("#log").html(), "0,keydown,", "Keydown HOME");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ESCAPE } );
- equals( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)");
+ equal( $("#log").html(), "1,keydown,", "Keydown ESCAPE (close submenu)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
}
function menukeyboard4() {
- equals( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
+ equal( $("#log").html(), "0,keydown,", "Keydown ENTER (open submenu)");
menu_log("keydown",true);
element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
- equals( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)");
+ equal( $("#log").html(), "Aberdeen,keydown,", "Keydown ENTER (select item)");
start();
}
menu_log("click");
menu_click(menu,"1");
menu_log("afterclick");
- equals( $("#log").html(), "afterclick,1,click,afterclick,click,", "Click order not valid.");
+ equal( $("#log").html(), "afterclick,1,click,afterclick,click,", "Click order not valid.");
});
test( "refresh", function() {
expect( 3 );
var menu = $( "#menu1" ).menu();
- equals(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items");
+ equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items");
menu.append("<li><a href='#'>test item</a></li>").menu("refresh");
- equals(menu.find(".ui-menu-item").length,6,"Incorrect number of menu items");
+ equal(menu.find(".ui-menu-item").length,6,"Incorrect number of menu items");
menu.find(".ui-menu-item:last").remove().end().menu("refresh");
- equals(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items");
+ equal(menu.find(".ui-menu-item").length,5,"Incorrect number of menu items");
});
test("destroy", function() {
menu_log("click",true);
menu_click(menu,"1");
menu_log("afterclick");
- equals( $("#log").html(), "afterclick,click,", "Click order not valid.");
+ equal( $("#log").html(), "afterclick,click,", "Click order not valid.");
});
test( "{ disabled: false }", function() {
menu_log("click",true);
menu_click(menu,"1");
menu_log("afterclick");
- equals( $("#log").html(), "afterclick,1,click,", "Click order not valid.");
+ equal( $("#log").html(), "afterclick,1,click,", "Click order not valid.");
});
})(jQuery);
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 40, left: 40 }, "left top, left top" );
+ deepEqual( $( "#elx" ).offset(), { top: 40, left: 40 }, "left top, left top" );
$( "#elx" ).position({
my: "left top",
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 60, left: 40 }, "left top, left bottom" );
+ deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "left top, left bottom" );
$( "#elx" ).position({
my: "left",
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 55, left: 50 }, "left, bottom" );
+ deepEqual( $( "#elx" ).offset(), { top: 55, left: 50 }, "left, bottom" );
$( "#elx" ).position({
my: "left foo",
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 45, left: 50 }, "left foo, bar baz" );
+ deepEqual( $( "#elx" ).offset(), { top: 45, left: 50 }, "left foo, bar baz" );
});
test( "multiple elements", function() {
collision: "none"
});
- same( result, elements );
+ deepEqual( result, elements );
var expected = { top: 10, left: 4 };
elements.each(function() {
- same( $( this ).offset(), expected );
+ deepEqual( $( this ).offset(), expected );
});
});
of: "#parent",
collision: "none"
});
- same( el.offset(), definition.result,
+ deepEqual( el.offset(), definition.result,
"Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) );
});
});
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 40, left: 40 }, "selector" );
+ deepEqual( $( "#elx" ).offset(), { top: 40, left: 40 }, "selector" );
$( "#elx" ).position({
my: "left top",
of: $( "#parentx"),
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 60, left: 40 }, "jQuery object" );
+ deepEqual( $( "#elx" ).offset(), { top: 60, left: 40 }, "jQuery object" );
$( "#elx" ).position({
my: "left top",
of: $( "#parentx" )[ 0 ],
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 40, left: 40 }, "DOM element" );
+ deepEqual( $( "#elx" ).offset(), { top: 40, left: 40 }, "DOM element" );
$( "#elx" ).position({
my: "right bottom",
of: document,
collision: "none"
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: $( document ).height() - 10,
left: $( document ).width() - 10
}, "document" );
of: $( document ),
collision: "none"
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: $( document ).height() - 10,
left: $( document ).width() - 10
}, "document as jQuery object" );
of: window,
collision: "none"
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: $( window ).height() - 10,
left: $( window ).width() - 10
}, "window" );
of: $( window ),
collision: "none"
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: $( window ).height() - 10,
left: $( window ).width() - 10
}, "window as jQuery object" );
of: window,
collision: "none"
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: $( window ).height() + 500 - 10,
left: $( window ).width() + 200 - 10
}, "window, scrolled" );
of: event,
collision: "none"
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: 300,
left: 200
}, "event - left top, left top" );
of: event,
collision: "none"
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: 600,
left: 400
}, "event - left top, right bottom" );
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 70, left: 50 }, "offsets in at" );
+ deepEqual( $( "#elx" ).offset(), { top: 70, left: 50 }, "offsets in at" );
$( "#elx" ).position({
my: "left+10 top-10",
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 50, left: 50 }, "offsets in my" );
+ deepEqual( $( "#elx" ).offset(), { top: 50, left: 50 }, "offsets in my" );
$( "#elx" ).position({
my: "left top",
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 58, left: 50 }, "percentage offsets in at" );
+ deepEqual( $( "#elx" ).offset(), { top: 58, left: 50 }, "percentage offsets in at" );
$( "#elx" ).position({
my: "left-30% top+50%",
of: "#parentx",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" );
+ deepEqual( $( "#elx" ).offset(), { top: 65, left: 37 }, "percentage offsets in my" );
});
test( "using", function() {
at: "left top",
of: "#parentx",
using: function( position ) {
- same( this, elems[ count ], "correct context for call #" + count );
- same( position, expectedPosition, "correct position for call #" + count );
+ deepEqual( this, elems[ count ], "correct context for call #" + count );
+ deepEqual( position, expectedPosition, "correct position for call #" + count );
count++;
}
});
elems.each(function() {
- same( $( this ).offset(), originalPosition, "elements not moved" );
+ deepEqual( $( this ).offset(), originalPosition, "elements not moved" );
});
});
at: "right bottom",
of: window
}, config ) );
- same( elem.offset(), result, msg );
+ deepEqual( elem.offset(), result, msg );
}
function collisionTest2( config, result, msg ) {
at: "right center"
});
- same( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
+ deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
elem.position( {
my: "right center",
at: "left center"
})
- same( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
+ deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
});
test( "addClass: flipped top", function() {
at: "right bottom"
});
- same( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' );
+ deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' );
elem.position( {
my: "left bottom",
at: "right top"
});
- same( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' );
+ deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' );
});
test( "addClass: flipped right", function() {
at: "left center"
});
- same( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' );
+ deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' );
elem.position( {
my: "left center",
at: "right center"
});
- same( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' );
+ deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' );
});
at: "right top"
});
- same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' );
+ deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' );
elem.position( {
my: "left top",
at: "right bottom"
});
- same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' );
+ deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' );
});
test( "fractions", function() {
of: "#fractions-parent",
collision: "none"
});
- same( $( "#fractions-element" ).offset(), $( "#fractions-parent" ).offset(), "left top, left top" );
+ deepEqual( $( "#fractions-element" ).offset(), $( "#fractions-parent" ).offset(), "left top, left top" );
});
test( "bug #5280: consistent results (avoid fractional values)", function() {
of: wrapper,
collision: "none"
}).offset();
- same( offset1, offset2 );
+ deepEqual( offset1, offset2 );
});
}( jQuery ) );
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "left top, left top" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "left top, left top" );
$( "#elx" ).position({
my: "left top",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "left top, left bottom" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "left top, left bottom" );
$( "#elx" ).position({
my: "left",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 55, left: addLeft + 50 }, "left, bottom" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 55, left: addLeft + 50 }, "left, bottom" );
$( "#elx" ).position({
my: "left foo",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 45, left: addLeft +50 }, "left foo, bar baz" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 45, left: addLeft +50 }, "left foo, bar baz" );
});
test( "multiple elements", function() {
within: $("#within-container")
});
- same( result, elements );
+ deepEqual( result, elements );
var expected = { top: addTop + 10, left: addLeft + 4 };
elements.each(function() {
- same( $( this ).addOffsets(), expected );
+ deepEqual( $( this ).addOffsets(), expected );
});
});
collision: "none",
within: $("#within-container")
});
- same( el.addOffsets(), definition.result,
+ deepEqual( el.addOffsets(), definition.result,
"Position via " + QUnit.jsDump.parse({ my:definition.my, at:definition.at }) );
});
});
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "selector" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "selector" );
$( "#elx" ).position({
my: "left top",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "jQuery object" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 60, left: addLeft + 40 }, "jQuery object" );
$( "#elx" ).position({
my: "left top",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "DOM element" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 40, left: addLeft + 40 }, "DOM element" );
var event = $.extend( $.Event( "someEvent" ), { pageX: 200, pageY: 300 } );
$( "#elx" ).position({
collision: "none",
within: within
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: 300,
left: 200
}, "event - left top, left top" );
collision: "none",
within: within
});
- same( $( "#elx" ).offset(), {
+ deepEqual( $( "#elx" ).offset(), {
top: 600,
left: 400
}, "event - left top, right bottom" );
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 70, left: addLeft + 50 }, "offsets in at" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 70, left: addLeft + 50 }, "offsets in at" );
$( "#elx" ).position({
my: "left+10 top-10",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 50, left: addLeft + 50 }, "offsets in my" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 50, left: addLeft + 50 }, "offsets in my" );
$( "#elx" ).position({
my: "left top",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 58, left: addLeft + 50 }, "percentage offsets in at" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 58, left: addLeft + 50 }, "percentage offsets in at" );
$( "#elx" ).position({
my: "left-30% top+50%",
collision: "none",
within: within
});
- same( $( "#elx" ).addOffsets(), { top: addTop + 65, left: addLeft + 37 }, "percentage offsets in my" );
+ deepEqual( $( "#elx" ).addOffsets(), { top: addTop + 65, left: addLeft + 37 }, "percentage offsets in my" );
});
test( "using", function() {
using: function( position ) {
position.top -= within.offset().top;
position.left -= within.offset().left;
- same( this, elems[ count ], "correct context for call #" + count );
- same( position, expectedPosition, "correct position for call #" + count );
+ deepEqual( this, elems[ count ], "correct context for call #" + count );
+ deepEqual( position, expectedPosition, "correct position for call #" + count );
count++;
},
within: within
});
elems.each(function() {
- same( $( this ).addOffsets(), originalPosition, "elements not moved" );
+ deepEqual( $( this ).addOffsets(), originalPosition, "elements not moved" );
});
});
within: within
}, config ) );
- same( elem.addOffsets(), result, msg );
+ deepEqual( elem.addOffsets(), result, msg );
}
function collisionTest2( config, result, msg ) {
at: "right center"
});
- same( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
+ deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Has ui-flipped-left class' );
elem.position( {
my: "right center",
at: "left center"
})
- same( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
+ deepEqual( elem.hasClass( 'ui-flipped-left' ), false, 'Removed ui-flipped-left class' );
});
test( "addClass: flipped top", function() {
at: "right bottom"
});
- same( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' );
+ deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Has ui-flipped-top class' );
elem.position( {
my: "left bottom",
at: "right top"
});
- same( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' );
+ deepEqual( elem.hasClass( 'ui-flipped-top' ), false, 'Removed ui-flipped-top class' );
});
test( "addClass: flipped right", function() {
at: "left center"
});
- same( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' );
+ deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Has ui-flipped-right class' );
elem.position( {
my: "left center",
at: "right center"
});
- same( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' );
+ deepEqual( elem.hasClass( 'ui-flipped-right' ), false, 'Removed ui-flipped-right class' );
});
at: "right top"
});
- same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' );
+ deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Has ui-flipped-bottom class' );
elem.position( {
my: "left top",
at: "right bottom"
});
- same( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' );
+ deepEqual( elem.hasClass( 'ui-flipped-bottom' ), false, 'Removed ui-flipped-bottom class' );
});
}( jQuery ) );
offset: "10",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 70, left: 50 }, "single value" );
+ deepEqual( $( "#elx" ).offset(), { top: 70, left: 50 }, "single value" );
$( "#elx" ).position({
my: "left top",
offset: "5 -3",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 57, left: 45 }, "two values" );
+ deepEqual( $( "#elx" ).offset(), { top: 57, left: 45 }, "two values" );
$( "#elx" ).position({
my: "left top",
offset: "5px -3px",
collision: "none"
});
- same( $( "#elx" ).offset(), { top: 57, left: 45 }, "with units" );
+ deepEqual( $( "#elx" ).offset(), { top: 57, left: 45 }, "with units" );
});
}( jQuery ) );
expect(7);
el = $("#progressbar").progressbar();
- equals(el.attr("role"), "progressbar", "aria role");
- equals(el.attr("aria-valuemin"), 0, "aria-valuemin");
- equals(el.attr("aria-valuemax"), 100, "aria-valuemax");
- equals(el.attr("aria-valuenow"), 0, "aria-valuenow initially");
+ equal(el.attr("role"), "progressbar", "aria role");
+ equal(el.attr("aria-valuemin"), 0, "aria-valuemin");
+ equal(el.attr("aria-valuemax"), 100, "aria-valuemax");
+ equal(el.attr("aria-valuenow"), 0, "aria-valuenow initially");
el.progressbar("value", 77);
- equals(el.attr("aria-valuenow"), 77, "aria-valuenow");
+ equal(el.attr("aria-valuenow"), 77, "aria-valuenow");
el.progressbar("disable");
- equals(el.attr("aria-disabled"), "true", "aria-disabled on");
+ equal(el.attr("aria-disabled"), "true", "aria-disabled on");
el.progressbar("enable");
// FAIL: for some reason IE6 and 7 return a boolean false instead of the string
- equals(el.attr("aria-disabled"), "false", "aria-disabled off");
+ equal(el.attr("aria-disabled"), "false", "aria-disabled off");
});
})(jQuery);
$("#progressbar").progressbar({
value: 5,
create: function() {
- same(5, $(this).progressbar("value") );
+ deepEqual(5, $(this).progressbar("value") );
},
change: function() {
ok(false, 'create() has triggered change()');
expect(1);
$("#progressbar").progressbar({
change: function() {
- same( 5, $(this).progressbar("value") );
+ deepEqual( 5, $(this).progressbar("value") );
}
}).progressbar("value", 5);
});
expect( 3 );
var changes = 0,
value;
-
+
$( "#progressbar" ).progressbar({
change: function() {
changes++;
- same( $( this ).progressbar( "value" ), value, "change at " + value );
+ deepEqual( $( this ).progressbar( "value" ), value, "change at " + value );
},
complete: function() {
equal( changes, 2, "complete triggered after change" );
}
});
-
+
value = 5;
$( "#progressbar" ).progressbar( "value", value );
value = 100;
var expected = $('<div></div>').progressbar(),
actual = expected.progressbar('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test('value', function() {
expect(3);
-
+
var el = $('<div></div>').progressbar({ value: 20 });
- equals(el.progressbar('value'), 20, 'correct value as getter');
- equals(el.progressbar('value', 30), el, 'chainable as setter');
- equals(el.progressbar('option', 'value'), 30, 'correct value after setter');
+ equal(el.progressbar('value'), 20, 'correct value as getter');
+ equal(el.progressbar('value', 30), el, 'chainable as setter');
+ equal(el.progressbar('option', 'value'), 30, 'correct value after setter');
});
})(jQuery);
test("{ value : 0 }, default", function() {
$("#progressbar").progressbar();
- same( 0, $("#progressbar").progressbar("value") );
+ deepEqual( 0, $("#progressbar").progressbar("value") );
});
// Ticket #7231 - valueDiv should be hidden when value is at 0%
$("#progressbar").progressbar({
value: 5
});
- same( 5, $("#progressbar").progressbar("value") );
+ deepEqual( 5, $("#progressbar").progressbar("value") );
});
test("{ value : -5 }", function() {
$("#progressbar").progressbar({
value: -5
});
- same( 0, $("#progressbar").progressbar("value") );
+ deepEqual( 0, $("#progressbar").progressbar("value") );
});
test("{ value : 105 }", function() {
$("#progressbar").progressbar({
value: 105
});
- same( 100, $("#progressbar").progressbar("value") );
+ deepEqual( 100, $("#progressbar").progressbar("value") );
});
test("{ max : 5, value : 10 }", function() {
max: 5,
value: 10
});
- same( 5, $("#progressbar").progressbar("value") );
+ deepEqual( 5, $("#progressbar").progressbar("value") );
});
})(jQuery);
$(el).simulate("mouseover");
return $(el).simulate("drag", {
- dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
+ dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
});
};
var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 0, -50);
- equals( target.height(), 150, "compare height" );
+ equal( target.height(), 150, "compare height" );
drag(handle, 0, 50);
- equals( target.height(), 100, "compare height" );
+ equal( target.height(), 100, "compare height" );
});
test("s", function() {
var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 0, 50);
- equals( target.height(), 150, "compare height" );
+ equal( target.height(), 150, "compare height" );
drag(handle, 0, -50);
- equals( target.height(), 100, "compare height" );
+ equal( target.height(), 100, "compare height" );
});
test("e", function() {
var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 50);
- equals( target.width(), 150, "compare width");
+ equal( target.width(), 150, "compare width");
drag(handle, -50);
- equals( target.width(), 100, "compare width" );
+ equal( target.width(), 100, "compare width" );
});
test("w", function() {
var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, -50);
- equals( target.width(), 150, "compare width" );
+ equal( target.width(), 150, "compare width" );
drag(handle, 50);
- equals( target.width(), 100, "compare width" );
+ equal( target.width(), 100, "compare width" );
});
test("ne", function() {
var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' });
drag(handle, -50, -50);
- equals( target.width(), 50, "compare width" );
- equals( target.height(), 150, "compare height" );
+ equal( target.width(), 50, "compare width" );
+ equal( target.height(), 150, "compare height" );
drag(handle, 50, 50);
- equals( target.width(), 100, "compare width" );
- equals( target.height(), 100, "compare height" );
+ equal( target.width(), 100, "compare width" );
+ equal( target.height(), 100, "compare height" );
});
test("se", function() {
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, 50, 50);
- equals( target.width(), 150, "compare width" );
- equals( target.height(), 150, "compare height" );
+ equal( target.width(), 150, "compare width" );
+ equal( target.height(), 150, "compare height" );
drag(handle, -50, -50);
- equals( target.width(), 100, "compare width" );
- equals( target.height(), 100, "compare height" );
+ equal( target.width(), 100, "compare width" );
+ equal( target.height(), 100, "compare height" );
});
test("sw", function() {
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, -50, -50);
- equals( target.width(), 150, "compare width" );
- equals( target.height(), 50, "compare height" );
+ equal( target.width(), 150, "compare width" );
+ equal( target.height(), 50, "compare height" );
drag(handle, 50, 50);
- equals( target.width(), 100, "compare width" );
- equals( target.height(), 100, "compare height" );
+ equal( target.width(), 100, "compare width" );
+ equal( target.height(), 100, "compare height" );
});
test("nw", function() {
var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' });
drag(handle, -50, -50);
- equals( target.width(), 150, "compare width" );
- equals( target.height(), 150, "compare height" );
+ equal( target.width(), 150, "compare width" );
+ equal( target.height(), 150, "compare height" );
drag(handle, 50, 50);
- equals( target.width(), 100, "compare width" );
- equals( target.height(), 100, "compare height" );
+ equal( target.width(), 100, "compare width" );
+ equal( target.height(), 100, "compare height" );
});
})(jQuery);
var expected = $('<div></div>').resizable(),
actual = expected.resizable('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test("enable", function() {
var expected = $('<div></div>').resizable(),
actual = expected.resizable('enable');
- equals(actual, expected, 'enable is chainable');
+ equal(actual, expected, 'enable is chainable');
ok(false, "missing test - untested code is broken code.");
});
test("disable", function() {
var expected = $('<div></div>').resizable(),
actual = expected.resizable('disable');
- equals(actual, expected, 'disable is chainable');
+ equal(actual, expected, 'disable is chainable');
ok(false, "missing test - untested code is broken code.");
});
var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 80);
- equals( target.width(), 130, "compare maxWidth");
- equals( target.height(), 130, "compare maxHeight");
+ equal( target.width(), 130, "compare maxWidth");
+ equal( target.height(), 130, "compare maxHeight");
drag(handle, -130);
- equals( target.width(), 70, "compare minWidth");
- equals( target.height(), 70, "compare minHeight");
+ equal( target.width(), 70, "compare minWidth");
+ equal( target.height(), 70, "compare minHeight");
});
test("aspectRatio: 'preserve' (w)", function() {
var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, -80);
- equals( target.width(), 130, "compare maxWidth");
- equals( target.height(), 130, "compare maxHeight");
+ equal( target.width(), 130, "compare maxWidth");
+ equal( target.height(), 130, "compare maxHeight");
drag(handle, 130);
- equals( target.width(), 70, "compare minWidth");
- equals( target.height(), 70, "compare minHeight");
+ equal( target.width(), 70, "compare minWidth");
+ equal( target.height(), 70, "compare minHeight");
});
test("aspectRatio: 'preserve' (n)", function() {
var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 0, -80);
- equals( target.width(), 130, "compare maxWidth");
- equals( target.height(), 130, "compare maxHeight");
+ equal( target.width(), 130, "compare maxWidth");
+ equal( target.height(), 130, "compare maxHeight");
drag(handle, 0, 80);
- equals( target.width(), 70, "compare minWidth");
- equals( target.height(), 70, "compare minHeight");
+ equal( target.width(), 70, "compare minWidth");
+ equal( target.height(), 70, "compare minHeight");
});
test("aspectRatio: 'preserve' (s)", function() {
var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 0, 80);
- equals( target.width(), 130, "compare maxWidth");
- equals( target.height(), 130, "compare maxHeight");
+ equal( target.width(), 130, "compare maxWidth");
+ equal( target.height(), 130, "compare maxHeight");
drag(handle, 0, -80);
- equals( target.width(), 70, "compare minWidth");
- equals( target.height(), 70, "compare minHeight");
+ equal( target.width(), 70, "compare minWidth");
+ equal( target.height(), 70, "compare minHeight");
});
test("aspectRatio: 'preserve' (se)", function() {
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 80, 80);
- equals( target.width(), 130, "compare maxWidth");
- equals( target.height(), 130, "compare maxHeight");
+ equal( target.width(), 130, "compare maxWidth");
+ equal( target.height(), 130, "compare maxHeight");
drag(handle, -80, -80);
- equals( target.width(), 70, "compare minWidth");
- equals( target.height(), 70, "compare minHeight");
+ equal( target.width(), 70, "compare minWidth");
+ equal( target.height(), 70, "compare minHeight");
});
test("aspectRatio: 'preserve' (sw)", function() {
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, -80, 80);
- equals( target.width(), 130, "compare maxWidth");
- equals( target.height(), 130, "compare maxHeight");
+ equal( target.width(), 130, "compare maxWidth");
+ equal( target.height(), 130, "compare maxHeight");
drag(handle, 80, -80);
- equals( target.width(), 70, "compare minWidth");
- equals( target.height(), 70, "compare minHeight");
+ equal( target.width(), 70, "compare minWidth");
+ equal( target.height(), 70, "compare minHeight");
});
test("aspectRatio: 'preserve' (ne)", function() {
var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
drag(handle, 80, -80);
- equals( target.width(), 130, "compare maxWidth");
- equals( target.height(), 130, "compare maxHeight");
+ equal( target.width(), 130, "compare maxWidth");
+ equal( target.height(), 130, "compare maxHeight");
drag(handle, -80, 80);
- equals( target.width(), 70, "compare minWidth");
- equals( target.height(), 70, "compare minHeight");
+ equal( target.width(), 70, "compare minWidth");
+ equal( target.height(), 70, "compare minHeight");
});
test("grid", function() {
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] });
drag(handle, 3, 9);
- equals( target.width(), 103, "compare width");
- equals( target.height(), 100, "compare height");
+ equal( target.width(), 103, "compare width");
+ equal( target.height(), 100, "compare height");
drag(handle, 15, 11);
- equals( target.width(), 118, "compare width");
- equals( target.height(), 120, "compare height");
+ equal( target.width(), 118, "compare width");
+ equal( target.height(), 120, "compare height");
});
test("grid (wrapped)", function() {
var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] });
drag(handle, 3, 9);
- equals( target.width(), 103, "compare width");
- equals( target.height(), 100, "compare height");
+ equal( target.width(), 103, "compare width");
+ equal( target.height(), 100, "compare height");
drag(handle, 15, 11);
- equals( target.width(), 118, "compare width");
- equals( target.height(), 120, "compare height");
+ equal( target.width(), 118, "compare width");
+ equal( target.height(), 120, "compare height");
});
test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, -50, -50);
- equals( target.width(), 60, "compare minWidth" );
- equals( target.height(), 60, "compare minHeight" );
+ equal( target.width(), 60, "compare minWidth" );
+ equal( target.height(), 60, "compare minHeight" );
drag(handle, 70, 70);
- equals( target.width(), 100, "compare maxWidth" );
- equals( target.height(), 100, "compare maxHeight" );
+ equal( target.width(), 100, "compare maxWidth" );
+ equal( target.height(), 100, "compare maxHeight" );
});
test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, 50, -50);
- equals( target.width(), 60, "compare minWidth" );
- equals( target.height(), 60, "compare minHeight" );
+ equal( target.width(), 60, "compare minWidth" );
+ equal( target.height(), 60, "compare minHeight" );
drag(handle, -70, 70);
- equals( target.width(), 100, "compare maxWidth" );
- equals( target.height(), 100, "compare maxHeight" );
+ equal( target.width(), 100, "compare maxWidth" );
+ equal( target.height(), 100, "compare maxHeight" );
});
test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, -50, 50);
- equals( target.width(), 60, "compare minWidth" );
- equals( target.height(), 60, "compare minHeight" );
+ equal( target.width(), 60, "compare minWidth" );
+ equal( target.height(), 60, "compare minHeight" );
drag(handle, 70, -70);
- equals( target.width(), 100, "compare maxWidth" );
- equals( target.height(), 100, "compare maxHeight" );
+ equal( target.width(), 100, "compare maxWidth" );
+ equal( target.height(), 100, "compare maxHeight" );
});
test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
drag(handle, 70, 70);
- equals( target.width(), 60, "compare minWidth" );
- equals( target.height(), 60, "compare minHeight" );
+ equal( target.width(), 60, "compare minWidth" );
+ equal( target.height(), 60, "compare minHeight" );
drag(handle, -70, -70);
- equals( target.width(), 100, "compare maxWidth" );
- equals( target.height(), 100, "compare maxHeight" );
+ equal( target.width(), 100, "compare maxWidth" );
+ equal( target.height(), 100, "compare maxHeight" );
});
})(jQuery);
el.selectable({
start: function(ev, ui) {
ok(true, "drag fired start callback");
- equals(this, el[0], "context of callback");
+ equal(this, el[0], "context of callback");
}
});
el.simulate("drag", 20, 20);
el.selectable({
start: function(ev, ui) {
ok(true, "drag fired stop callback");
- equals(this, el[0], "context of callback");
+ equal(this, el[0], "context of callback");
}
});
el.simulate("drag", 20, 20);
var expected = $('<div></div>').selectable(),
actual = expected.selectable('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test("enable", function() {
start: function() { fired = true; }
});
el.simulate("drag", 20, 20);
- equals(fired, false, "start fired");
+ equal(fired, false, "start fired");
el.selectable("enable");
el.simulate("drag", 20, 20);
- equals(fired, true, "start fired");
+ equal(fired, true, "start fired");
el.selectable("destroy");
-
+
var expected = $('<div></div>').selectable(),
actual = expected.selectable('enable');
- equals(actual, expected, 'enable is chainable');
+ equal(actual, expected, 'enable is chainable');
});
test("disable", function() {
start: function() { fired = true; }
});
el.simulate("drag", 20, 20);
- equals(fired, true, "start fired");
+ equal(fired, true, "start fired");
el.selectable("disable");
fired = false;
el.simulate("drag", 20, 20);
- equals(fired, false, "start fired");
+ equal(fired, false, "start fired");
el.selectable("destroy");
-
+
var expected = $('<div></div>').selectable(),
actual = expected.selectable('disable');
- equals(actual, expected, 'disable is chainable');
+ equal(actual, expected, 'disable is chainable');
});
})(jQuery);
el = $("#selectable1").selectable({ autoRefresh: false, selected: selected });
sel.hide();
drag(1000, 1000);
- equals(actual, sel.length);
+ equal(actual, sel.length);
el.selectable("destroy");
actual = 0;
el = $("#selectable1").selectable({ autoRefresh: true, selected: selected });
sel.hide();
drag(1000, 1000);
- equals(actual, 0);
+ equal(actual, 0);
sel.show();
drag(1000, 1000);
- equals(actual, sel.length);
+ equal(actual, sel.length);
el.selectable("destroy");
sel.show();
});
el = $("#selectable1").selectable({ filter: '.special', selected: selected });
drag(1000, 1000);
ok(sel.length != 1, "this test assumes more than 1 selectee");
- equals(actual, 1);
+ equal(actual, 1);
el.selectable("destroy");
});
el.slider("value", 0);
handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
- el.slider('destroy');
+ el.slider('destroy');
el = $('<div></div>');
options = {
el.slider("value", 0);
handle().simulate("keydown", { keyCode: $.ui.keyCode.HOME });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
el.slider('destroy');
});
el.slider("value", 0);
handle().simulate("keydown", { keyCode: $.ui.keyCode.END });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
- el.slider('destroy');
+ el.slider('destroy');
el = $('<div></div>');
options = {
el.slider("value", 0);
handle().simulate("keydown", { keyCode: $.ui.keyCode.END });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
el.slider('destroy');
});
el.slider("value", 70);
handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_UP });
- equals(el.slider("value"), 90);
+ equal(el.slider("value"), 90);
handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_UP });
- equals(el.slider("value"), 100);
+ equal(el.slider("value"), 100);
el.slider("destroy");
});
el.slider("value", 30);
handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_DOWN });
- equals(el.slider("value"), 10);
+ equal(el.slider("value"), 10);
handle().simulate("keydown", { keyCode: $.ui.keyCode.PAGE_DOWN });
- equals(el.slider("value"), 0);
+ equal(el.slider("value"), 0);
el.slider("destroy");
});
el.slider("value", options.max - options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.UP });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
handle().simulate("keydown", { keyCode: $.ui.keyCode.UP });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
- el.slider("destroy");
+ el.slider("destroy");
el = $('<div></div>');
options = {
el.slider("value", options.max - options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.UP });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
handle().simulate("keydown", { keyCode: $.ui.keyCode.UP });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
- el.slider("destroy");
+ el.slider("destroy");
});
test("keydown RIGHT on handle increases value by step, not greater than max", function() {
el.slider("value", options.max - options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
- el.slider("destroy");
+ el.slider("destroy");
el = $('<div></div>');
options = {
el.slider("value", options.max - options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
handle().simulate("keydown", { keyCode: $.ui.keyCode.RIGHT });
- equals(el.slider("value"), options.max);
+ equal(el.slider("value"), options.max);
- el.slider("destroy");
+ el.slider("destroy");
});
test("keydown DOWN on handle decreases value by step, not less than min", function() {
el.slider("value", options.min + options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
- el.slider("destroy");
+ el.slider("destroy");
el = $('<div></div>');
options = {
el.slider("value", options.min + options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
handle().simulate("keydown", { keyCode: $.ui.keyCode.DOWN });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
- el.slider("destroy");
+ el.slider("destroy");
});
test("keydown LEFT on handle decreases value by step, not less than min", function() {
el.slider("value", options.min + options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
- el.slider("destroy");
+ el.slider("destroy");
el = $('<div></div>');
options = {
el.slider("value", options.min + options.step);
handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
handle().simulate("keydown", { keyCode: $.ui.keyCode.LEFT });
- equals(el.slider("value"), options.min);
+ equal(el.slider("value"), options.min);
- el.slider("destroy");
+ el.slider("destroy");
});
})(jQuery);
* slider_events.js
*/
(function($) {
-
+
module( "slider: events" );
//Specs from http://wiki.jqueryui.com/Slider#specs
// or value method/option"
test( "mouse based interaction", function() {
expect(4);
-
+
var el = $( "<div></div>" )
.appendTo( "body" )
.slider({
start: function(event, ui) {
- equals( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
+ equal( event.originalEvent.type, "mousedown", "start triggered by mousedown" );
},
slide: function(event, ui) {
- equals( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
+ equal( event.originalEvent.type, "mousemove", "slider triggered by mousemove" );
},
stop: function(event, ui) {
- equals( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
+ equal( event.originalEvent.type, "mouseup", "stop triggered by mouseup" );
},
change: function(event, ui) {
- equals( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
+ equal( event.originalEvent.type, "mouseup", "change triggered by mouseup" );
}
});
});
test( "keyboard based interaction", function() {
expect(3);
-
+
// Test keyup at end of handle slide (keyboard)
var el = $( "<div></div>" )
.appendTo( "body" )
.slider({
start: function(event, ui) {
- equals( event.originalEvent.type, "keydown", "start triggered by keydown" );
+ equal( event.originalEvent.type, "keydown", "start triggered by keydown" );
},
slide: function(event, ui) {
ok( false, "Slider never triggered by keys" );
},
stop: function(event, ui) {
- equals( event.originalEvent.type, "keyup", "stop triggered by keyup" );
+ equal( event.originalEvent.type, "keyup", "stop triggered by keyup" );
},
change: function(event, ui) {
- equals( event.originalEvent.type, "keyup", "change triggered by keyup" );
+ equal( event.originalEvent.type, "keyup", "change triggered by keyup" );
}
});
});
test( "programmatic event triggers", function() {
expect(6);
-
+
// Test value method
var el = $( "<div></div>" )
.slider({
var expected = $('<div></div>').slider(),
actual = expected.slider('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test("enable", function() {
var expected = $('<div></div>').slider(),
actual = expected.slider('enable');
- equals(actual, expected, 'enable is chainable');
+ equal(actual, expected, 'enable is chainable');
var el = $('<div></div>').slider({ disabled: true });
ok(el.hasClass('ui-disabled'), 'slider has ui-disabled class before enable method call');
test("disable", function() {
var expected = $('<div></div>').slider(),
actual = expected.slider('disable');
- equals(actual, expected, 'disable is chainable');
+ equal(actual, expected, 'disable is chainable');
var el = $('<div></div>').slider({ disabled: false });
ok(!el.hasClass('ui-disabled'), 'slider does not have ui-disabled class before disabled method call');
range: this,
value: 5
});
- equals(el.slider('value'), 5, 'range: ' + this + ' slider method get');
- equals(el.slider('value', 10), el, 'value method is chainable');
- equals(el.slider('value'), 10, 'range: ' + this + ' slider method set');
+ equal(el.slider('value'), 5, 'range: ' + this + ' slider method get');
+ equal(el.slider('value', 10), el, 'value method is chainable');
+ equal(el.slider('value'), 10, 'range: ' + this + ' slider method set');
el.remove();
});
var el = $('<div></div>').slider({
});
// min with value option vs value method
el.slider('option', 'value', -2);
- equals(el.slider('option', 'value'), -2, 'value option does not respect min');
- equals(el.slider('value'), -1, 'value method get respects min');
- equals(el.slider('value', -2), el, 'value method is chainable');
- equals(el.slider('option', 'value'), -1, 'value method set respects min');
+ equal(el.slider('option', 'value'), -2, 'value option does not respect min');
+ equal(el.slider('value'), -1, 'value method get respects min');
+ equal(el.slider('value', -2), el, 'value method is chainable');
+ equal(el.slider('option', 'value'), -1, 'value method set respects min');
// max with value option vs value method
el.slider('option', 'value', 2);
- equals(el.slider('option', 'value'), 2, 'value option does not respect max');
- equals(el.slider('value'), 1, 'value method get respects max');
- equals(el.slider('value', 2), el, 'value method is chainable');
- equals(el.slider('option', 'value'), 1, 'value method set respects max');
+ equal(el.slider('option', 'value'), 2, 'value option does not respect max');
+ equal(el.slider('value'), 1, 'value method get respects max');
+ equal(el.slider('value', 2), el, 'value method is chainable');
+ equal(el.slider('option', 'value'), 1, 'value method set respects max');
});
//test("values", function() {
test("max", function() {
el = $('<div></div>');
-
+
options = {
max: 37,
min: 6,
test("min", function() {
el = $('<div></div>');
-
+
options = {
max: 37,
min: 6,
el.slider(options).slider("option", "orientation", "horizontal");
ok(el.is('.ui-slider-horizontal'), "horizontal slider has class .ui-slider-horizontal");
ok(!el.is('.ui-slider-vertical'), "horizontal slider does not have class .ui-slider-vertical");
- equals(handle().css('left'), percentVal + '%', "horizontal slider handle is positioned with left: %");
+ equal(handle().css('left'), percentVal + '%', "horizontal slider handle is positioned with left: %");
el.slider('destroy');
el.slider(options).slider("option", "orientation", "vertical");
ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical");
ok(!el.is('.ui-slider-horizontal'), "vertical slider does not have class .ui-slider-horizontal");
- equals(handle().css('bottom'), percentVal + '%', "vertical slider handle is positioned with bottom: %");
+ equal(handle().css('bottom'), percentVal + '%', "vertical slider handle is positioned with bottom: %");
el.slider('destroy');
step: 10,
max: 100
});
- equals( el.slider("value"), 0 );
+ equal( el.slider("value"), 0 );
el.slider("value", 1);
- equals( el.slider("value"), 0 );
+ equal( el.slider("value"), 0 );
el.slider("value", 9);
- equals( el.slider("value"), 10 );
+ equal( el.slider("value"), 10 );
el.slider("value", 11);
- equals( el.slider("value"), 10 );
+ equal( el.slider("value"), 10 );
el.slider("value", 19);
- equals( el.slider("value"), 20 );
+ equal( el.slider("value"), 20 );
el = $('<div></div>').slider({
min: 0,
el.slider("value", 0);
el.slider("option", "value", 1);
- equals( el.slider("value"), 0 );
+ equal( el.slider("value"), 0 );
el.slider("option", "value", 9);
- equals( el.slider("value"), 0 );
+ equal( el.slider("value"), 0 );
el.slider("option", "value", 11);
- equals( el.slider("value"), 20 );
+ equal( el.slider("value"), 20 );
el.slider("option", "value", 19);
- equals( el.slider("value"), 20 );
+ equal( el.slider("value"), 20 );
el.slider('destroy');
});
var sort = function(handle, dx, dy, index, msg) {
drag(handle, dx, dy);
- equals($(handle).parent().children().index(handle), index, msg);
+ equal($(handle).parent().children().index(handle), index, msg);
}
module("sortable: methods");
var expected = $('<div></div>').sortable(),
actual = expected.sortable('destroy');
- equals(actual, expected, 'destroy is chainable');
+ equal(actual, expected, 'destroy is chainable');
});
test("enable", function() {
sort($("li", el)[0], 0, 40, 0, '.sortable({ disabled: true })');
el.sortable("enable");
- equals(el.sortable("option", "disabled"), false, "disabled option getter");
+ equal(el.sortable("option", "disabled"), false, "disabled option getter");
el.sortable("destroy");
el.sortable({ disabled: true });
el.sortable("option", "disabled", false);
- equals(el.sortable("option", "disabled"), false, "disabled option setter");
+ equal(el.sortable("option", "disabled"), false, "disabled option setter");
sort($("li", el)[0], 0, 40, 2, '.sortable("option", "disabled", false)');
-
+
var expected = $('<div></div>').sortable(),
actual = expected.sortable('enable');
- equals(actual, expected, 'enable is chainable');
+ equal(actual, expected, 'enable is chainable');
});
test("disable", function() {
el.sortable({ disabled: false });
sort($("li", el)[0], 0, 40, 2, '.sortable({ disabled: false })');
el.sortable("option", "disabled", true);
- equals(el.sortable("option", "disabled"), true, "disabled option setter");
+ equal(el.sortable("option", "disabled"), true, "disabled option setter");
ok(el.sortable("widget").is(":not(.ui-state-disabled)"), "sortable element does not get ui-state-disabled since it's an interaction");
sort($("li", el)[0], 0, 40, 0, '.sortable("option", "disabled", true)');
-
+
var expected = $('<div></div>').sortable(),
actual = expected.sortable('disable');
- equals(actual, expected, 'disable is chainable');
+ equal(actual, expected, 'disable is chainable');
});
})(jQuery);
var sort = function(handle, dx, dy, index, msg) {
drag(handle, dx, dy);
- equals($(handle).parent().children().index(handle), index, msg);
+ equal($(handle).parent().children().index(handle), index, msg);
}
module("sortable: tickets");
});
sort($("li", el)[0], 0, 40, 2, 'Dragging the sortable');
- equals(helper, null, "helper should be false");
+ equal(helper, null, "helper should be false");
});
ok( element.is( ":disabled"), "after: input has disabled attribute" );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( 2, element.val(), "keyboard - value does not change on key UP" );
+ equal( 2, element.val(), "keyboard - value does not change on key UP" );
spinner_simulateKeyDownUp( element, $.ui.keyCode.DOWN );
- equals( 2, element.val(), "keyboard - value does not change on key DOWN" );
+ equal( 2, element.val(), "keyboard - value does not change on key DOWN" );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_UP );
- equals( 2, element.val(), "keyboard - value does not change on key PGUP" );
+ equal( 2, element.val(), "keyboard - value does not change on key PGUP" );
spinner_simulateKeyDownUp( element, $.ui.keyCode.PAGE_DOWN );
- equals( 2, element.val(), "keyboard - value does not change on key PGDN" );
+ equal( 2, element.val(), "keyboard - value does not change on key PGDN" );
wrapper.find( ".ui-spinner-up" ).trigger( "mousedown" ).trigger( "mouseup" );
- equals( 2, element.val(), "mouse - value does not change on clicking up button" );
+ equal( 2, element.val(), "mouse - value does not change on clicking up button" );
wrapper.find( ".ui-spinner-down" ).trigger( "mousedown" ).trigger( "mouseup" );
- equals( 2, element.val(), "mouse - value does not change on clicking down button" );
+ equal( 2, element.val(), "mouse - value does not change on clicking down button" );
element.spinner( "stepUp", 6 );
- equals( 8, element.val(), "script - stepUp 6 steps changes value");
+ equal( 8, element.val(), "script - stepUp 6 steps changes value");
element.spinner( "stepDown" );
- equals( 7, element.val(), "script - stepDown 1 step changes value" );
+ equal( 7, element.val(), "script - stepDown 1 step changes value" );
element.spinner( "pageUp" );
- equals( 17, element.val(), "script - pageUp 1 page changes value" );
+ equal( 17, element.val(), "script - pageUp 1 page changes value" );
element.spinner( "pageDown" );
- equals( 7, element.val(), "script - pageDown 1 page changes value" );
+ equal( 7, element.val(), "script - pageDown 1 page changes value" );
});
test( "enable", function() {
ok( !element.is( ":disabled" ), "after: input does not have disabled attribute" );
spinner_simulateKeyDownUp( element, $.ui.keyCode.UP );
- equals( 2, element.val(), "keyboard - value changes on key UP" );
+ equal( 2, element.val(), "keyboard - value changes on key UP" );
});
test( "pageDown", function() {
});
element.spinner( "pageDown" );
- equals( element.val(), -32, "pageDown 1 page" );
+ equal( element.val(), -32, "pageDown 1 page" );
element.spinner( "pageDown", 3 );
- equals( element.val(), -92, "pageDown 3 pages" );
+ equal( element.val(), -92, "pageDown 3 pages" );
element.spinner( "pageDown" );
- equals( element.val(), -100, "value close to min and pageDown 1 page" );
+ equal( element.val(), -100, "value close to min and pageDown 1 page" );
element.spinner( "pageDown", 10 );
- equals( element.val(), -100, "value at min and pageDown 10 pages" );
+ equal( element.val(), -100, "value at min and pageDown 10 pages" );
});
test( "pageUp", function() {
});
element.spinner( "pageUp" );
- equals( element.val(), 32, "pageUp 1 page" );
+ equal( element.val(), 32, "pageUp 1 page" );
element.spinner( "pageUp", 3 );
- equals( element.val(), 92, "pageUp 3 pages" );
+ equal( element.val(), 92, "pageUp 3 pages" );
element.spinner( "pageUp" );
- equals( element.val(), 100, "value close to max and pageUp 1 page" );
+ equal( element.val(), 100, "value close to max and pageUp 1 page" );
element.spinner( "pageUp", 10 );
- equals( element.val(), 100, "value at max and pageUp 10 pages" );
+ equal( element.val(), 100, "value at max and pageUp 10 pages" );
});
test( "stepDown", function() {
});
element.spinner( "stepDown" );
- equals( element.val(), "-1", "stepDown 1 step" );
+ equal( element.val(), "-1", "stepDown 1 step" );
element.spinner( "stepDown", 5 );
- equals( element.val(), "-11", "stepDown 5 steps" );
+ equal( element.val(), "-11", "stepDown 5 steps" );
element.spinner( "stepDown", 4 );
- equals( element.val(), "-15", "close to min and stepDown 4 steps" );
+ equal( element.val(), "-15", "close to min and stepDown 4 steps" );
element.spinner( "stepDown" );
- equals( element.val(), "-15", "at min and stepDown 1 step" );
+ equal( element.val(), "-15", "at min and stepDown 1 step" );
});
test( "stepUp", function() {
});
element.spinner( "stepUp" );
- equals( element.val(), 2, "stepUp 1 step" );
+ equal( element.val(), 2, "stepUp 1 step" );
element.spinner( "stepUp", 5 );
- equals( element.val(), 12, "stepUp 5 steps" );
+ equal( element.val(), 12, "stepUp 5 steps" );
element.spinner( "stepUp", 4 );
- equals( element.val(), 16, "close to min and stepUp 4 steps" );
+ equal( element.val(), 16, "close to min and stepUp 4 steps" );
element.spinner( "stepUp" );
- equals( element.val(), 16, "at max and stepUp 1 step" );
+ equal( element.val(), 16, "at max and stepUp 1 step" );
});
test( "value", function() {
});
element.spinner( "value", 10 );
- equals( element.val(), 9, "change value via value method" );
+ equal( element.val(), 9, "change value via value method" );
- equals( element.spinner( "value" ), 9, "get value via value method" );
+ equal( element.spinner( "value" ), 9, "get value via value method" );
});
})( jQuery );
test( "max", function() {
expect( 3 );
var element = $( "#spin" ).val( 1000 ).spinner({ max: 100 });
- equals( element.val(), 1000, "value not constrained on init" );
+ equal( element.val(), 1000, "value not constrained on init" );
element.spinner( "value", 1000 );
- equals( element.val(), 100, "max constrained in value method" );
+ equal( element.val(), 100, "max constrained in value method" );
element.val( 1000 ).blur();
- equals( element.val(), 1000, "max not constrained if manual entry" );
+ equal( element.val(), 1000, "max not constrained if manual entry" );
});
test( "max, string", function() {
numberFormat: "C",
culture: "en"
});
- equals( element.val(), "$1,000.00", "value not constrained on init" );
- equals( element.spinner( "option", "max" ), 100, "option converted to number" );
+ equal( element.val(), "$1,000.00", "value not constrained on init" );
+ equal( element.spinner( "option", "max" ), 100, "option converted to number" );
element.spinner( "value", 1000 );
- equals( element.val(), "$100.00", "max constrained in value method" );
+ equal( element.val(), "$100.00", "max constrained in value method" );
});
test( "min", function() {
expect( 3 );
var element = $( "#spin" ).val( -1000 ).spinner({ min: -100 });
- equals( element.val(), -1000, "value not constrained on init" );
+ equal( element.val(), -1000, "value not constrained on init" );
element.spinner( "value", -1000 );
- equals( element.val(), -100, "min constrained in value method" );
+ equal( element.val(), -100, "min constrained in value method" );
element.val( -1000 ).blur();
- equals( element.val(), -1000, "min not constrained if manual entry" );
+ equal( element.val(), -1000, "min not constrained if manual entry" );
});
test( "min, string", function() {
numberFormat: "C",
culture: "en"
});
- equals( element.val(), "($1,000.00)", "value not constrained on init" );
- equals( element.spinner( "option", "min" ), -100, "option converted to number" );
+ equal( element.val(), "($1,000.00)", "value not constrained on init" );
+ equal( element.spinner( "option", "min" ), -100, "option converted to number" );
element.spinner( "value", -1000 );
- equals( element.val(), "($100.00)", "min constrained in value method")
+ equal( element.val(), "($100.00)", "min constrained in value method")
});
test( "step, 2", function() {
var element = $( "#spin" ).val( 0 ).spinner({ step: 2 });
element.spinner( "stepUp" );
- equals( element.val(), "2", "stepUp" );
+ equal( element.val(), "2", "stepUp" );
element.spinner( "value", "10.5" );
- equals( element.val(), "10", "value reset to 10" );
+ equal( element.val(), "10", "value reset to 10" );
element.val( "4.5" );
element.spinner( "stepUp" );
- equals( element.val(), "6", "stepUp" );
+ equal( element.val(), "6", "stepUp" );
});
test( "step, 0.7", function() {
});
element.spinner( "stepUp" );
- equals( element.val(), "0.7", "stepUp" );
+ equal( element.val(), "0.7", "stepUp" );
});
test( "step, string", function() {
culture: "en"
});
- equals( element.spinner( "option", "step" ), 0.7, "option converted to number" );
+ equal( element.spinner( "option", "step" ), 0.7, "option converted to number" );
element.spinner( "stepUp" );
- equals( element.val(), "$0.70", "stepUp" );
+ equal( element.val(), "$0.70", "stepUp" );
});
})( jQuery );
}
return -1; // mixed state - invalid
}).get();
- same( actual, expected );
+ deepEqual( actual, expected );
}
function tabs_disabled( tabs, state ) {
}
return -1; // mixed state - invalid
}).get();
- same( tabs.tabs( "option", "disabled" ), state );
- same( actual, expected );
+ deepEqual( tabs.tabs( "option", "disabled" ), state );
+ deepEqual( actual, expected );
}
</script>
<script src="../swarminject.js"></script>
expect( 1 );
var element = $( "#tabs6" ).tabs();
- equals( element.data( "tabs" ).anchors.length, 2, "should contain 2 tab" );
+ equal( element.data( "tabs" ).anchors.length, 2, "should contain 2 tab" );
});
test( "disconnected from DOM", function() {
expect( 2 );
var element = $( "#tabs1" ).remove().tabs();
- equals( element.find( ".ui-tabs-nav" ).length, 1, "should initialize nav" );
- equals( element.find( ".ui-tabs-panel" ).length, 3, "should initialize panels" );
+ equal( element.find( ".ui-tabs-nav" ).length, 1, "should initialize nav" );
+ equal( element.find( ".ui-tabs-panel" ).length, 3, "should initialize panels" );
});
test( "aria-controls", function() {
}
});
- equals( element.find( ".ui-tabs-nav a" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
+ equal( element.find( ".ui-tabs-nav a" ).attr( "aria-controls" ), "tab", "aria-contorls attribute is correct" );
tabs_state( element, 1 );
});
}
return -1; // mixed state - invalid
}).get();
- same( actual, expected );
+ deepEqual( actual, expected );
}
function tabs_disabled( tabs, state ) {
}
return -1; // mixed state - invalid
}).get();
- same( tabs.tabs( "option", "disabled" ), state );
- same( actual, expected );
+ deepEqual( tabs.tabs( "option", "disabled" ), state );
+ deepEqual( actual, expected );
}
</script>
<script src="../swarminject.js"></script>
}
});
element.one( "tabsload", function( event, ui ) {
- equals( $( ui.panel ).html(), "test" );
+ equal( $( ui.panel ).html(), "test" );
start();
});
element.tabs( "option", "active", 2 );
setTimeout(function() {
element.tabs( "option", "active", 0 );
tabs_state( element, 1, 0, 0, 0, 0 );
-
+
element.one( "tabsshow", function( event, ui ) {
tabs_state( element, 0, 0, 1, 0, 0 );
});
element.tabs( "add", "#new", "New" );
var tab = element.find( ".ui-tabs-nav li" ).last(),
anchor = tab.find( "a" );
- equals( tab.text(), "New", "label" );
+ equal( tab.text(), "New", "label" );
ok( tab.hasClass( "customTab" ), "tab custom class" );
- equals( anchor.attr( "href" ), "http://example.com/#new", "href" );
- equals( anchor.attr( "aria-controls" ), "new", "aria-controls" );
+ equal( anchor.attr( "href" ), "http://example.com/#new", "href" );
+ equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" );
});
}
element.tabs({ cookie: cookieObj });
- equals( cookie(), 0, "initial cookie value" );
+ equal( cookie(), 0, "initial cookie value" );
element.tabs( "destroy" );
element.tabs({ active: 1, cookie: cookieObj });
- equals( cookie(), 1, "initial cookie value, from active property" );
+ equal( cookie(), 1, "initial cookie value, from active property" );
element.tabs( "option", "active", 2 );
- equals( cookie(), 2, "cookie value updated after activating" );
+ equal( cookie(), 2, "cookie value updated after activating" );
element.tabs( "destroy" );
$.cookie( cookieName, 1 );
element.tabs({ cookie: cookieObj });
- equals( cookie(), 1, "initial cookie value, from existing cookie" );
+ equal( cookie(), 1, "initial cookie value, from existing cookie" );
element.tabs( "destroy" );
element.tabs({ cookie: cookieObj, collapsible: true });
element.tabs( "option", "active", false );
- equals( cookie(), -1, "cookie value for all tabs unselected" );
+ equal( cookie(), -1, "cookie value for all tabs unselected" );
element.tabs( "destroy" );
ok( $.cookie( cookieName ) === null, "erase cookie after destroy" );
var element = $( "#tabs2" ).tabs();
element.one( "tabsbeforeload", function( event, ui ) {
- equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 1, "beforeload" );
+ equal( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 1, "beforeload" );
});
element.one( "tabsload", function( event, ui ) {
// wait until after the load finishes before checking for the spinner to be removed
setTimeout(function() {
- equals( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" );
+ equal( element.find( ".ui-tabs-nav li:eq(2) em" ).length, 0, "load" );
start();
}, 1 );
});
expect( 19 );
var element = $( "#tabs1" ).tabs();
- equals( element.tabs( "option", "selected" ), 0, "should be 0 by default" );
+ equal( element.tabs( "option", "selected" ), 0, "should be 0 by default" );
tabs_state( element, 1, 0, 0 );
element.tabs( "destroy" );
location.hash = "#fragment-3";
element = $( "#tabs1" ).tabs();
- equals( element.tabs( "option", "selected" ), 2, "should be 2 based on URL" );
+ equal( element.tabs( "option", "selected" ), 2, "should be 2 based on URL" );
tabs_state( element, 0, 0, 1 );
element.tabs( "destroy" );
element.tabs( "destroy" );
element.tabs({ selected: 2 });
- equals( element.tabs( "option", "selected" ), 2 );
+ equal( element.tabs( "option", "selected" ), 2 );
tabs_state( element, 0, 0, 1 );
element.tabs( "option", "selected", 0 );
- equals( element.tabs( "option", "selected" ), 0 );
+ equal( element.tabs( "option", "selected" ), 0 );
tabs_state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).click();
- equals( element.tabs( "option", "selected" ), 1 );
+ equal( element.tabs( "option", "selected" ), 1 );
tabs_state( element, 0, 1, 0 );
element.tabs( "option", "selected", 10 );
- equals( element.tabs( "option", "selected" ), 1 );
+ equal( element.tabs( "option", "selected" ), 1 );
tabs_state( element, 0, 1, 0 );
location.hash = "#";
ok( !( "originalEvent" in event ), "originalEvent" );
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
- equals( $( ui.panel ).find( "p" ).length, 1, "panel html" );
+ equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
tabs_state( element, 0, 0, 1, 0, 0 );
tabsload1();
});
ok( !( "originalEvent" in event ), "originalEvent" );
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
- equals( $( ui.panel ).find( "p" ).length, 1, "panel html" );
+ equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
tabs_state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- equals( event.originalEvent.type, "click", "originalEvent" );
+ equal( event.originalEvent.type, "click", "originalEvent" );
strictEqual( ui.tab, tab[ 0 ], "tab" );
strictEqual( ui.panel, panel[ 0 ], "panel" );
- equals( $( ui.panel ).find( "p" ).length, 1, "panel html" );
+ equal( $( ui.panel ).find( "p" ).length, 1, "panel html" );
tabs_state( element, 0, 0, 0, 0, 1 );
start();
});
var element = $( "#tabs1" ).tabs({
disabled: [ 0, 1 ],
enable: function( event, ui ) {
- equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
- equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
- equals( ui.index, 1, "ui.index" );
+ equal( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
+ equal( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
+ equal( ui.index, 1, "ui.index" );
}
});
element.tabs( "enable", 1 );
var element = $( "#tabs1" ).tabs({
disable: function( event, ui ) {
- equals( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
- equals( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
- equals( ui.index, 1, "ui.index" );
+ equal( ui.tab, element.find( ".ui-tabs-nav a" )[ 1 ], "ui.tab" );
+ equal( ui.panel, element.find( ".ui-tabs-panel" )[ 1 ], "ui.panel" );
+ equal( ui.index, 1, "ui.index" );
}
});
element.tabs( "disable", 1 );
// switching tabs
element.one( "tabsshow", function( event, ui ) {
- equals( event.originalEvent.type, "click", "originalEvent" );
+ equal( event.originalEvent.type, "click", "originalEvent" );
strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
// switching tabs
element.one( "tabsselect", function( event, ui ) {
- equals( event.originalEvent.type, "click", "originalEvent" );
+ equal( event.originalEvent.type, "click", "originalEvent" );
strictEqual( ui.tab, tabs[ 1 ], "ui.tab" );
strictEqual( ui.panel, panels[ 1 ], "ui.panel" );
equal( ui.index, 1, "ui.index" );
tabs_state( element, 1, 0, 0, 0 );
var tab = element.find( ".ui-tabs-nav li" ).last(),
anchor = tab.find( "a" );
- equals( tab.text(), "New", "label" );
- equals( anchor.attr( "href" ), "#new", "href" );
- equals( anchor.attr( "aria-controls" ), "new", "aria-controls" );
+ equal( tab.text(), "New", "label" );
+ equal( anchor.attr( "href" ), "#new", "href" );
+ equal( anchor.attr( "aria-controls" ), "new", "aria-controls" );
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
anchor.simulate( "mouseover" );
ok( tab.hasClass( "ui-state-hover" ), "hovered" );
tabs_state( element, 0, 0, 0, 0, 1 );
tab = element.find( ".ui-tabs-nav li" ).eq( 1 );
anchor = tab.find( "a" );
- equals( tab.text(), "New Remote", "label" );
- equals( anchor.attr( "href" ), "data/test.html", "href" );
+ equal( tab.text(), "New Remote", "label" );
+ equal( anchor.attr( "href" ), "data/test.html", "href" );
ok( /^ui-tabs-\d+$/.test( anchor.attr( "aria-controls" ) ), "aria controls" );
ok( !tab.hasClass( "ui-state-hover" ), "not hovered" );
anchor.simulate( "mouseover" );
// add to empty tab set
element = $( "<div><ul></ul></div>" ).tabs();
- equals( element.tabs( "option", "active" ), false, "active: false on init" );
+ equal( element.tabs( "option", "active" ), false, "active: false on init" );
element.one( "tabsadd", function( event, ui ) {
equal( ui.index, 0, "ui.index" );
equal( $( ui.tab ).text(), "First", "ui.tab" );
});
element.tabs( "add", "#first", "First" );
tabs_state( element, 1 );
- equals( element.tabs( "option", "active" ), 0, "active: 0 after add" );
+ equal( element.tabs( "option", "active" ), 0, "active: 0 after add" );
});
test( "#5069 - ui.tabs.add creates two tab panels when using a full URL", function() {
expect( 2 );
var element = $( "#tabs2" ).tabs();
- equals( element.children( "div" ).length, element.find( ".ui-tabs-nav li" ).length );
+ equal( element.children( "div" ).length, element.find( ".ui-tabs-nav li" ).length );
element.tabs( "add", "/new", "New" );
- equals( element.children( "div" ).length, element.find( ".ui-tabs-nav li" ).length );
+ equal( element.children( "div" ).length, element.find( ".ui-tabs-nav li" ).length );
});
test( "remove", function() {
});
element.tabs( "remove", 1 );
tabs_state( element, 0, 1 );
- equals( element.tabs( "option", "active" ), 1 );
- equals( element.find( ".ui-tabs-nav li a[href$='fragment-2']" ).length, 0,
+ equal( element.tabs( "option", "active" ), 1 );
+ equal( element.find( ".ui-tabs-nav li a[href$='fragment-2']" ).length, 0,
"remove correct list item" );
- equals( element.find( "#fragment-2" ).length, 0, "remove correct panel" );
+ equal( element.find( "#fragment-2" ).length, 0, "remove correct panel" );
element.one( "tabsremove", function( event, ui ) {
equal( ui.index, -1, "ui.index" );
});
element.tabs( "remove", 1 );
tabs_state( element, 1 );
- equals( element.tabs( "option", "active"), 0 );
+ equal( element.tabs( "option", "active"), 0 );
element.one( "tabsremove", function( event, ui ) {
equal( ui.index, -1, "ui.index" );
equal( ui.panel.id, "fragment-1", "ui.panel" );
});
element.tabs( "remove", 0 );
- equals( element.tabs( "option", "active" ), false );
+ equal( element.tabs( "option", "active" ), false );
});
test( "select", function() {
tabs_state( element, 1, 0, 0 );
element.tabs( "select", 1 );
tabs_state( element, 0, 1, 0 );
- equals( element.tabs( "option", "active" ), 1, "active" );
- equals( element.tabs( "option", "selected" ), 1, "selected" );
+ equal( element.tabs( "option", "active" ), 1, "active" );
+ equal( element.tabs( "option", "selected" ), 1, "selected" );
element.tabs( "destroy" );
element.tabs({ collapsible: true });
tabs_state( element, 1, 0, 0 );
element.tabs( "select", 0 );
tabs_state( element, 0, 0, 0 );
- equals( element.tabs( "option", "active" ), false, "active" );
- equals( element.tabs( "option", "selected" ), -1, "selected" );
+ equal( element.tabs( "option", "active" ), false, "active" );
+ equal( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
element.tabs({ collapsible: true });
element.tabs( "select", -1 );
tabs_state( element, 0, 0, 0 );
- equals( element.tabs( "option", "active" ), false, "active" );
- equals( element.tabs( "option", "selected" ), -1, "selected" );
+ equal( element.tabs( "option", "active" ), false, "active" );
+ equal( element.tabs( "option", "selected" ), -1, "selected" );
element.tabs( "destroy" );
element.tabs();
tabs_state( element, 1, 0, 0 );
- equals( element.tabs( "option", "active" ), 0, "active" );
- equals( element.tabs( "option", "selected" ), 0, "selected" );
+ equal( element.tabs( "option", "active" ), 0, "active" );
+ equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", 0 );
tabs_state( element, 1, 0, 0 );
- equals( element.tabs( "option", "active" ), 0, "active" );
- equals( element.tabs( "option", "selected" ), 0, "selected" );
+ equal( element.tabs( "option", "active" ), 0, "active" );
+ equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", -1 );
tabs_state( element, 1, 0, 0 );
- equals( element.tabs( "option", "active" ), 0, "active" );
- equals( element.tabs( "option", "selected" ), 0, "selected" );
+ equal( element.tabs( "option", "active" ), 0, "active" );
+ equal( element.tabs( "option", "selected" ), 0, "selected" );
element.tabs( "select", "#fragment-2" );
tabs_state( element, 0, 1, 0 );
- equals( element.tabs( "option", "active" ), 1, "active" );
- equals( element.tabs( "option", "selected" ), 1, "selected" );
+ equal( element.tabs( "option", "active" ), 1, "active" );
+ equal( element.tabs( "option", "selected" ), 1, "selected" );
});
test( "length", function() {
expect( 2 );
- equals( $( "#tabs1" ).tabs().tabs( "length" ), 3, "basic tabs" );
- equals( $( "#tabs2" ).tabs().tabs( "length" ), 5, "ajax tabs with missing panels" );
+ equal( $( "#tabs1" ).tabs().tabs( "length" ), 3, "basic tabs" );
+ equal( $( "#tabs2" ).tabs().tabs( "length" ), 5, "ajax tabs with missing panels" );
});
test( "url", function() {
tab = element.find( "a" ).eq( 3 );
element.tabs( "url", 3, "data/test2.html" );
- equals( tab.attr( "href" ), "data/test2.html", "href was updated" );
+ equal( tab.attr( "href" ), "data/test2.html", "href was updated" );
element.one( "tabsbeforeload", function( event, ui ) {
- equals( ui.ajaxSettings.url, "data/test2.html", "ajaxSettings.url" );
+ equal( ui.ajaxSettings.url, "data/test2.html", "ajaxSettings.url" );
event.preventDefault();
});
element.tabs( "option", "active", 3 );
var element = $( "#tabs2" ).tabs();
element.one( "tabsbeforeload", function( event, ui ) {
ui.jqXHR.error(function( jqXHR, status ) {
- equals( status, "abort", "aborted" );
+ equal( status, "abort", "aborted" );
start();
});
});
element.tabs({
create: function( event, ui ) {
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tabs[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panels[ 0 ], "panel" );
}
});
element.tabs({
active: 2,
create: function( event, ui ) {
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tabs[ 2 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panels[ 2 ], "panel" );
}
});
active: false,
collapsible: true,
create: function( event, ui ) {
- equals( ui.tab.size(), 0, "tab size" );
- equals( ui.panel.size(), 0, "panel size" );
+ equal( ui.tab.size(), 0, "tab size" );
+ equal( ui.panel.size(), 0, "panel size" );
}
});
element.tabs( "destroy" );
// from collapsed
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.oldTab.size(), 0, "oldTab size" );
- equals( ui.oldPanel.size(), 0, "oldPanel size" );
- equals( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.oldTab.size(), 0, "oldTab size" );
+ equal( ui.oldPanel.size(), 0, "oldPanel size" );
+ equal( ui.newTab.size(), 1, "newTab size" );
strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
- equals( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.size(), 1, "newPanel size" );
strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
tabs_state( element, 0, 0, 0 );
});
// switching tabs
element.one( "tabsbeforeactivate", function( event, ui ) {
- equals( event.originalEvent.type, "click", "originalEvent" );
- equals( ui.oldTab.size(), 1, "oldTab size" );
+ equal( event.originalEvent.type, "click", "originalEvent" );
+ equal( ui.oldTab.size(), 1, "oldTab size" );
strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
- equals( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.size(), 1, "oldPanel size" );
strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
- equals( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.newTab.size(), 1, "newTab size" );
strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equals( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.size(), 1, "newPanel size" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
tabs_state( element, 1, 0, 0 );
});
// collapsing
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.oldTab.size(), 1, "oldTab size" );
+ equal( ui.oldTab.size(), 1, "oldTab size" );
strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
- equals( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.size(), 1, "oldPanel size" );
strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
- equals( ui.newTab.size(), 0, "newTab size" );
- equals( ui.newPanel.size(), 0, "newPanel size" );
+ equal( ui.newTab.size(), 0, "newTab size" );
+ equal( ui.newPanel.size(), 0, "newPanel size" );
tabs_state( element, 0, 1, 0 );
});
element.tabs( "option", "active", false );
// prevent activation
element.one( "tabsbeforeactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.oldTab.size(), 0, "oldTab size" );
- equals( ui.oldPanel.size(), 0, "oldTab" );
- equals( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.oldTab.size(), 0, "oldTab size" );
+ equal( ui.oldPanel.size(), 0, "oldTab" );
+ equal( ui.newTab.size(), 1, "newTab size" );
strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equals( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.size(), 1, "newPanel size" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
event.preventDefault();
tabs_state( element, 0, 0, 0 );
// from collapsed
element.one( "tabsactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.oldTab.size(), 0, "oldTab size" );
- equals( ui.oldPanel.size(), 0, "oldPanel size" );
- equals( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.oldTab.size(), 0, "oldTab size" );
+ equal( ui.oldPanel.size(), 0, "oldPanel size" );
+ equal( ui.newTab.size(), 1, "newTab size" );
strictEqual( ui.newTab[ 0 ], tabs[ 0 ], "newTab" );
- equals( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.size(), 1, "newPanel size" );
strictEqual( ui.newPanel[ 0 ], panels[ 0 ], "newPanel" );
tabs_state( element, 1, 0, 0 );
});
// switching tabs
element.one( "tabsactivate", function( event, ui ) {
- equals( event.originalEvent.type, "click", "originalEvent" );
- equals( ui.oldTab.size(), 1, "oldTab size" );
+ equal( event.originalEvent.type, "click", "originalEvent" );
+ equal( ui.oldTab.size(), 1, "oldTab size" );
strictEqual( ui.oldTab[ 0 ], tabs[ 0 ], "oldTab" );
- equals( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.size(), 1, "oldPanel size" );
strictEqual( ui.oldPanel[ 0 ], panels[ 0 ], "oldPanel" );
- equals( ui.newTab.size(), 1, "newTab size" );
+ equal( ui.newTab.size(), 1, "newTab size" );
strictEqual( ui.newTab[ 0 ], tabs[ 1 ], "newTab" );
- equals( ui.newPanel.size(), 1, "newPanel size" );
+ equal( ui.newPanel.size(), 1, "newPanel size" );
strictEqual( ui.newPanel[ 0 ], panels[ 1 ], "newPanel" );
tabs_state( element, 0, 1, 0 );
});
// collapsing
element.one( "tabsactivate", function( event, ui ) {
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.oldTab.size(), 1, "oldTab size" );
+ equal( ui.oldTab.size(), 1, "oldTab size" );
strictEqual( ui.oldTab[ 0 ], tabs[ 1 ], "oldTab" );
- equals( ui.oldPanel.size(), 1, "oldPanel size" );
+ equal( ui.oldPanel.size(), 1, "oldPanel size" );
strictEqual( ui.oldPanel[ 0 ], panels[ 1 ], "oldPanel" );
- equals( ui.newTab.size(), 0, "newTab size" );
- equals( ui.newPanel.size(), 0, "newPanel size" );
+ equal( ui.newTab.size(), 0, "newTab size" );
+ equal( ui.newPanel.size(), 0, "newPanel size" );
tabs_state( element, 0, 0, 0 );
});
element.tabs( "option", "active", false );
ok( !( "originalEvent" in event ), "originalEvent" );
ok( "abort" in ui.jqXHR, "jqXHR" );
ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equals( ui.panel.html(), "", "panel html" );
+ equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
tabs_state( element, 0, 0, 1, 0, 0 );
});
element.tabs({ active: 2 });
tabs_state( element, 0, 0, 1, 0, 0 );
- equals( panel.html(), "", "panel html after" );
+ equal( panel.html(), "", "panel html after" );
element.tabs( "destroy" );
// .option()
ok( !( "originalEvent" in event ), "originalEvent" );
ok( "abort" in ui.jqXHR, "jqXHR" );
ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equals( ui.panel.html(), "", "panel html" );
+ equal( ui.panel.html(), "", "panel html" );
event.preventDefault();
tabs_state( element, 1, 0, 0, 0, 0 );
});
element.tabs();
element.tabs( "option", "active", 2 );
tabs_state( element, 0, 0, 1, 0, 0 );
- equals( panel.html(), "", "panel html after" );
+ equal( panel.html(), "", "panel html after" );
// click, change panel content
element.one( "tabsbeforeload", function( event, ui ) {
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- equals( event.originalEvent.type, "click", "originalEvent" );
+ equal( event.originalEvent.type, "click", "originalEvent" );
ok( "abort" in ui.jqXHR, "jqXHR" );
ok( ui.ajaxSettings.url, "data/test.html", "ajaxSettings.url" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
ui.panel.html( "<p>testing</p>" );
event.preventDefault();
element.find( ".ui-tabs-nav a" ).eq( 3 ).click();
tabs_state( element, 0, 0, 0, 1, 0 );
// .toLowerCase() is needed to convert <P> to <p> in old IEs
- equals( panel.html().toLowerCase(), "<p>testing</p>", "panel html after" );
+ equal( panel.html().toLowerCase(), "<p>testing</p>", "panel html after" );
});
if ( $.uiBackCompat === false ) {
tab = element.find( ".ui-tabs-nav a" ).eq( 2 );
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
-
+
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ equal( ui.panel.find( "p" ).length, 1, "panel html" );
tabs_state( element, 0, 0, 1, 0, 0 );
tabsload1();
});
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ equal( ui.panel.find( "p" ).length, 1, "panel html" );
tabs_state( element, 0, 0, 0, 1, 0 );
tabsload2();
});
panelId = tab.attr( "aria-controls" );
panel = $( "#" + panelId );
- equals( event.originalEvent.type, "click", "originalEvent" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( event.originalEvent.type, "click", "originalEvent" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
- equals( ui.panel.find( "p" ).length, 1, "panel html" );
+ equal( ui.panel.find( "p" ).length, 1, "panel html" );
tabs_state( element, 0, 0, 0, 0, 1 );
start();
});
element.tabs( "refresh" );
tabs_state( element, 1, 0, 0, 0 );
tabs_disabled( element, [ 1 ] );
- equals( element.find( "#" + $( "#newTab a" ).attr( "aria-controls" ) ).length, 1,
+ equal( element.find( "#" + $( "#newTab a" ).attr( "aria-controls" ) ).length, 1,
"panel added for remote tab" );
// remove all tabs
element.find( ".ui-tabs-nav li, .ui-tabs-panel" ).remove();
element.tabs( "refresh" );
tabs_state( element );
- equals( element.tabs( "option", "active" ), false, "no active tab" );
+ equal( element.tabs( "option", "active" ), false, "no active tab" );
// add tabs
element.find( ".ui-tabs-nav" )
element.tabs( "refresh" );
tabs_state( element, 0, 1 );
tabs_disabled( element, [ 0 ] );
-
+
// remove first tab, previously active tab (now first) should stay active
element.find( ".ui-tabs-nav li" ).eq( 0 ).remove();
element.find( ".ui-tabs-panel" ).eq( 0 ).remove();
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
tabs_state( element, 1, 0, 0, 0, 0 );
});
var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
-
+
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( uiTab.size(), 1, "tab size" );
+ equal( uiTab.size(), 1, "tab size" );
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
- equals( uiPanel.size(), 1, "panel size" );
+ equal( uiPanel.size(), 1, "panel size" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
- equals( uiPanel.find( "p" ).length, 1, "panel html" );
+ equal( uiPanel.find( "p" ).length, 1, "panel html" );
tabs_state( element, 1, 0, 0, 0, 0 );
setTimeout( tabsload1, 100 );
});
panel = $( "#" + panelId );
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( ui.tab.size(), 1, "tab size" );
+ equal( ui.tab.size(), 1, "tab size" );
strictEqual( ui.tab[ 0 ], tab[ 0 ], "tab" );
- equals( ui.panel.size(), 1, "panel size" );
+ equal( ui.panel.size(), 1, "panel size" );
strictEqual( ui.panel[ 0 ], panel[ 0 ], "panel" );
tabs_state( element, 0, 0, 0, 1, 0 );
});
var tab = element.find( ".ui-tabs-nav a" ).eq( 3 ),
panelId = tab.attr( "aria-controls" ),
panel = $( "#" + panelId );
-
+
ok( !( "originalEvent" in event ), "originalEvent" );
- equals( uiTab.size(), 1, "tab size" );
+ equal( uiTab.size(), 1, "tab size" );
strictEqual( uiTab[ 0 ], tab[ 0 ], "tab" );
- equals( uiPanel.size(), 1, "panel size" );
+ equal( uiPanel.size(), 1, "panel size" );
strictEqual( uiPanel[ 0 ], panel[ 0 ], "panel" );
tabs_state( element, 0, 0, 0, 1, 0 );
start();
expect( 4 );
var element = $( "#tabs1" ).tabs();
- equals( element.tabs( "option", "active" ), 0, "should be 0 by default" );
+ equal( element.tabs( "option", "active" ), 0, "should be 0 by default" );
tabs_state( element, 1, 0, 0 );
element.tabs( "destroy" );
location.hash = "#fragment-3";
element = $( "#tabs1" ).tabs();
- equals( element.tabs( "option", "active" ), 2, "should be 2 based on URL" );
+ equal( element.tabs( "option", "active" ), 2, "should be 2 based on URL" );
tabs_state( element, 0, 0, 1 );
element.tabs( "destroy" );
location.hash = "#";
var element = $( "#tabs1" ).tabs({
active: 2
});
- equals( element.tabs( "option", "active" ), 2 );
+ equal( element.tabs( "option", "active" ), 2 );
tabs_state( element, 0, 0, 1 );
element.tabs( "option", "active", 0 );
- equals( element.tabs( "option", "active" ), 0 );
+ equal( element.tabs( "option", "active" ), 0 );
tabs_state( element, 1, 0, 0 );
element.find( ".ui-tabs-nav a" ).eq( 1 ).click();
- equals( element.tabs( "option", "active" ), 1 );
+ equal( element.tabs( "option", "active" ), 1 );
tabs_state( element, 0, 1, 0 );
element.tabs( "option", "active", 10 );
- equals( element.tabs( "option", "active" ), 1 );
+ equal( element.tabs( "option", "active" ), 1 );
tabs_state( element, 0, 1, 0 );
});
var element = $( "#tabs1" ).tabs({
active: -1
});
- equals( element.tabs( "option", "active" ), 2 );
+ equal( element.tabs( "option", "active" ), 2 );
tabs_state( element, 0, 0, 1 );
element.tabs( "option", "active", -2 );
- equals( element.tabs( "option", "active" ), 1 );
+ equal( element.tabs( "option", "active" ), 1 );
tabs_state( element, 0, 1, 0 );
element.tabs( "option", "active", -10 );
- equals( element.tabs( "option", "active" ), 1 );
+ equal( element.tabs( "option", "active" ), 1 );
tabs_state( element, 0, 1, 0 );
element.tabs( "option", "active", -3 );
- equals( element.tabs( "option", "active" ), 0 );
+ equal( element.tabs( "option", "active" ), 0 );
tabs_state( element, 1, 0, 0 );
});
}
location.hash = "#tabs7-2";
var element = $( "#tabs7" ).tabs();
- equals( element.tabs( "option", "active" ), 1, "should be 1 based on URL" );
+ equal( element.tabs( "option", "active" ), 1, "should be 1 based on URL" );
tabs_state( element, 0, 1 );
element.tabs( "option", "active", 0 );
tabs_state( element, 1, 0 );
ok( $.isFunction( pluginDefaults[ key ] ), key );
return;
}
- same( pluginDefaults[ key ], val, key );
+ deepEqual( pluginDefaults[ key ], val, key );
});
});
/*
* Experimental assertion for comparing DOM objects.
- *
+ *
* Serializes an element and some attributes and it's children if any, otherwise the text.
* Then compares the result using deepEqual.
*/
window.domEqual = function( selector, modifier, message ) {
var attributes = ["class", "role", "id", "tabIndex", "aria-activedescendant"];
-
+
function extract(value) {
if (!value || !value.length) {
QUnit.push( false, actual, expected, "domEqual failed, can't extract " + selector + ", message was: " + message );
}
var expected = extract($(selector));
modifier($(selector));
-
+
var actual = extract($(selector));
QUnit.push( QUnit.equiv(actual, expected), actual, expected, message );
}
var element = $( "#tooltipped1" ).tooltip();
element.one( "tooltipopen", function( event ) {
- same( event.originalEvent.type, "mouseover" );
+ deepEqual( event.originalEvent.type, "mouseover" );
});
element.trigger( "mouseover" );
element.one( "tooltipclose", function( event ) {
- same( event.originalEvent.type, "mouseleave" );
+ deepEqual( event.originalEvent.type, "mouseleave" );
});
element.trigger( "mouseleave" );
});
var element = $( "#tooltipped1" ).tooltip();
element.one( "tooltipopen", function( event ) {
- same( event.originalEvent.type, "focusin" );
+ deepEqual( event.originalEvent.type, "focusin" );
});
element.trigger( "focusin" );
element.one( "tooltipclose", function( event ) {
- same( event.originalEvent.type, "focusout" );
+ deepEqual( event.originalEvent.type, "focusout" );
});
element.trigger( "focusout" );
});
var element = $( "#tooltipped1" ).tooltip();
element.one( "tooltipopen", function( event ) {
- same( event.originalEvent.type, "focusin" );
+ deepEqual( event.originalEvent.type, "focusin" );
});
element.simulate( "focus" );
// blurring is async in IE
element.one( "tooltipclose", function( event ) {
- same( event.originalEvent.type, "focusout" );
+ deepEqual( event.originalEvent.type, "focusout" );
start();
});
element.simulate( "blur" );
can't return anything useful if no element is kept around and there's no useful reference
test("widget", function() {
var tooltip = $("#tooltipped1").tooltip();
- same(tooltip.tooltip("widget")[0], $(".ui-tooltip")[0]);
- same(tooltip.tooltip("widget").end()[0], tooltip[0]);
+ deepEqual(tooltip.tooltip("widget")[0], $(".ui-tooltip")[0]);
+ deepEqual(tooltip.tooltip("widget").end()[0], tooltip[0]);
});
*/
test( "content: default", function() {
var element = $( "#tooltipped1" ).tooltip().tooltip( "open" );
- same( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
+ deepEqual( $( "#" + element.attr( "aria-describedby" ) ).text(), "anchortitle" );
});
test( "content: return string", function() {
return "customstring";
}
}).tooltip( "open" );
- same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
+ deepEqual( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
test( "content: return jQuery", function() {
return $( "<div>" ).html( "cu<b>s</b>tomstring" );
}
}).tooltip( "open" );
- same( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
+ deepEqual( $( "#" + element.attr( "aria-describedby" ) ).text(), "customstring" );
});
asyncTest( "content: sync + async callback", function() {
var element = $( "#tooltipped1" ).tooltip({
content: function( response ) {
setTimeout(function() {
- same( $( "#" + element.attr("aria-describedby") ).text(), "loading..." );
+ deepEqual( $( "#" + element.attr("aria-describedby") ).text(), "loading..." );
response( "customstring2" );
setTimeout(function() {
- same( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" );
+ deepEqual( $( "#" + element.attr("aria-describedby") ).text(), "customstring2" );
start();
}, 13 );
}, 13 );
var event = $.Event( "mouseenter" );
event.target = $( "#fixture-span" )[ 0 ];
element.tooltip( "open", event );
- same( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
+ deepEqual( $( "#" + $( "#fixture-span" ).attr( "aria-describedby" ) ).text(), "title-text" );
// make sure default [title] doesn't get used
event.target = $( "#tooltipped1" )[ 0 ];
element.tooltip( "open", event );
- same( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
+ deepEqual( $( "#tooltipped1" ).attr( "aria-describedby" ), undefined );
element.tooltip( "destroy" );
});
$.widget( "ui.testWidget", myPrototype );
ok( $.isFunction( $.ui.testWidget ), "constructor was created" );
- equals( "object", typeof $.ui.testWidget.prototype, "prototype was created" );
- equals( $.ui.testWidget.prototype._create, myPrototype._create,
+ equal( "object", typeof $.ui.testWidget.prototype, "prototype was created" );
+ equal( $.ui.testWidget.prototype._create, myPrototype._create,
"create function is copied over" );
- equals( $.ui.testWidget.prototype.creationTest, myPrototype.creationTest,
+ equal( $.ui.testWidget.prototype.creationTest, myPrototype.creationTest,
"random function is copied over" );
- equals( $.ui.testWidget.prototype.option, $.Widget.prototype.option,
+ equal( $.ui.testWidget.prototype.option, $.Widget.prototype.option,
"option method copied over from base widget" );
});
// workaround for core ticket #8381
this.element.appendTo( "#qunit-fixture" );
ok( this.element.is( "div" ), "generated div" );
- same( this.element.data( "testWidget" ), this, "intance stored in .data()" );
+ deepEqual( this.element.data( "testWidget" ), this, "intance stored in .data()" );
};
$.ui.testWidget();
$.ui.testWidget.prototype.defaultElement = "<span data-test='pass'></span>";
$.ui.testWidget.prototype._create = function() {
ok( this.element.is( "span[data-test=pass]" ), "generated span with properties" );
- same( this.element.data( "testWidget" ), this, "instace stored in .data()" );
+ deepEqual( this.element.data( "testWidget" ), this, "instace stored in .data()" );
};
$.ui.testWidget();
elem = $( "<input>" );
$.ui.testWidget.prototype._create = function() {
- same( this.element[ 0 ], elem[ 0 ], "from element" );
- same( elem.data( "testWidget" ), this, "instace stored in .data()" );
+ deepEqual( this.element[ 0 ], elem[ 0 ], "from element" );
+ deepEqual( elem.data( "testWidget" ), this, "instace stored in .data()" );
};
$.ui.testWidget( {}, elem[ 0 ] );
elem = $( "<div>" );
$.ui.testWidget.prototype._create = function() {
- same( this.element[ 0 ], elem[ 0 ], "from jQuery object" );
- same( elem.data( "testWidget" ), this, "instace stored in .data()" );
+ deepEqual( this.element[ 0 ], elem[ 0 ], "from jQuery object" );
+ deepEqual( elem.data( "testWidget" ), this, "instace stored in .data()" );
};
$.ui.testWidget( {}, elem );
elem = $( "<div id='element-normalization-selector'></div>" )
.appendTo( "#qunit-fixture" );
$.ui.testWidget.prototype._create = function() {
- same( this.element[ 0 ], elem[ 0 ], "from selector" );
- same( elem.data( "testWidget" ), this, "instace stored in .data()" );
+ deepEqual( this.element[ 0 ], elem[ 0 ], "from selector" );
+ deepEqual( elem.data( "testWidget" ), this, "instace stored in .data()" );
};
$.ui.testWidget( {}, "#element-normalization-selector" );
},
methodWithParams: function( param1, param2 ) {
ok( true, "method called via .pluginName(methodName)" );
- equals( param1, "value1",
+ equal( param1, "value1",
"parameter passed via .pluginName(methodName, param)" );
- equals( param2, "value2",
+ equal( param2, "value2",
"multiple parameters passed via .pluginName(methodName, param, param)" );
return this;
shouldCreate = false;
var instance = elem.data( "testWidget" );
- equals( typeof instance, "object", "instance stored in .data(pluginName)" );
- equals( instance.element[0], elem[0], "element stored on widget" );
+ equal( typeof instance, "object", "instance stored in .data(pluginName)" );
+ equal( instance.element[0], elem[0], "element stored on widget" );
var ret = elem.testWidget( "methodWithParams", "value1", "value2" );
- equals( ret, elem, "jQuery object returned from method call" );
+ equal( ret, elem, "jQuery object returned from method call" );
ret = elem.testWidget( "getterSetterMethod" );
- equals( ret, 5, "getter/setter can act as getter" );
+ equal( ret, 5, "getter/setter can act as getter" );
ret = elem.testWidget( "getterSetterMethod", 30 );
- equals( ret, elem, "getter/setter method can be chainable" );
- equals( instance.getterSetterVal, 30, "getter/setter can act as setter" );
+ equal( ret, elem, "getter/setter method can be chainable" );
+ equal( instance.getterSetterVal, 30, "getter/setter can act as setter" );
ret = elem.testWidget( "jQueryObject" );
equal( ret[ 0 ], document.body, "returned jQuery object" );
equal( ret.end(), elem, "stack preserved" );
},
methodWithParams: function( param1, param2 ) {
ok( true, "method called dirctly" );
- equals( param1, "value1", "parameter passed via direct call" );
- equals( param2, "value2", "multiple parameters passed via direct call" );
+ equal( param1, "value1", "parameter passed via direct call" );
+ equal( param2, "value2", "multiple parameters passed via direct call" );
return this;
},
var instance = new $.ui.testWidget( {}, elem );
shouldCreate = false;
- equals( $( elem ).data( "testWidget" ), instance,
+ equal( $( elem ).data( "testWidget" ), instance,
"instance stored in .data(pluginName)" );
- equals( instance.element[ 0 ], elem, "element stored on widget" );
+ equal( instance.element[ 0 ], elem, "element stored on widget" );
var ret = instance.methodWithParams( "value1", "value2" );
- equals( ret, instance, "plugin returned from method call" );
+ equal( ret, instance, "plugin returned from method call" );
ret = instance.getterSetterMethod();
- equals( ret, 5, "getter/setter can act as getter" );
+ equal( ret, 5, "getter/setter can act as getter" );
instance.getterSetterMethod( 30 );
- equals( instance.getterSetterVal, 30, "getter/setter can act as setter" );
+ equal( instance.getterSetterVal, 30, "getter/setter can act as setter" );
});
test( "error handling", function() {
expect( 1 );
$.widget( "ui.testWidget", {
_create: function() {
- same( this.options, {
+ deepEqual( this.options, {
create: null,
disabled: false,
option1: "value1",
};
},
_create: function() {
- same( this.options, {
+ deepEqual( this.options, {
create: null,
disabled: false,
option1: "override1",
actions = [];
div.testWidget({ foo: "bar" });
- same( actions, [ "create", "init" ], "correct methods called on init" );
+ deepEqual( actions, [ "create", "init" ], "correct methods called on init" );
actions = [];
div.testWidget();
- same( actions, [ "init" ], "correct methods call on re-init" );
+ deepEqual( actions, [ "init" ], "correct methods call on re-init" );
actions = [];
div.testWidget({ foo: "bar" });
- same( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
+ deepEqual( actions, [ "optionfoo", "init" ], "correct methods called on re-init with options" );
});
test( "inheritance - options", function() {
}
});
- same( $.ui.testWidgetBase.prototype.options.obj, {
+ deepEqual( $.ui.testWidgetBase.prototype.options.obj, {
key1: "foo",
key2: "bar"
}, "base class option object not overridden");
- same( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ],
+ deepEqual( $.ui.testWidgetBase.prototype.options.arr, [ "testing" ],
"base class option array not overridden");
- same( $.ui.testWidgetExtension.prototype.options.obj, {
+ deepEqual( $.ui.testWidgetExtension.prototype.options.obj, {
key1: "baz",
key2: "bar"
}, "extension class option object extends base");
- same( $.ui.testWidgetExtension.prototype.options.arr, [ "alpha", "beta" ],
+ deepEqual( $.ui.testWidgetExtension.prototype.options.arr, [ "alpha", "beta" ],
"extension class option array overwrites base");
delete $.ui.testWidgetBase;
var instance;
$.widget( "ui.testWidget", {
method: function( a, b ) {
- same( this, instance, "this is correct in testWidget" );
- same( a, 5, "parameter passed to testWidget" );
- same( b, 20, "second parameter passed to testWidget" );
+ deepEqual( this, instance, "this is correct in testWidget" );
+ deepEqual( a, 5, "parameter passed to testWidget" );
+ deepEqual( b, 20, "second parameter passed to testWidget" );
return a + b;
}
});
$.widget( "ui.testWidget2", $.ui.testWidget, {
method: function( a, b ) {
- same( this, instance, "this is correct in testWidget2" );
- same( a, 5, "parameter passed to testWidget2" );
- same( b, 10, "parameter passed to testWidget2" );
+ deepEqual( this, instance, "this is correct in testWidget2" );
+ deepEqual( a, 5, "parameter passed to testWidget2" );
+ deepEqual( b, 10, "parameter passed to testWidget2" );
return this._super( a, b*2 );
}
});
$.widget( "ui.testWidget3", $.ui.testWidget2, {
method: function( a ) {
- same( this, instance, "this is correct in testWidget3" );
- same( a, 5, "parameter passed to testWidget3" );
+ deepEqual( this, instance, "this is correct in testWidget3" );
+ deepEqual( a, 5, "parameter passed to testWidget3" );
var ret = this._super( a, a*2 );
- same( ret, 25, "super returned value" );
+ deepEqual( ret, 25, "super returned value" );
}
});
var instance;
$.widget( "ui.testWidget", {
method: function( a, b ) {
- same( this, instance, "this is correct in testWidget" );
- same( a, 5, "parameter passed to testWidget" );
- same( b, 10, "second parameter passed to testWidget" );
+ deepEqual( this, instance, "this is correct in testWidget" );
+ deepEqual( a, 5, "parameter passed to testWidget" );
+ deepEqual( b, 10, "second parameter passed to testWidget" );
return a + b;
}
});
$.widget( "ui.testWidget2", $.ui.testWidget, {
method: function( a, b ) {
- same( this, instance, "this is correct in testWidget2" );
- same( a, 5, "parameter passed to testWidget2" );
- same( b, 10, "second parameter passed to testWidget2" );
+ deepEqual( this, instance, "this is correct in testWidget2" );
+ deepEqual( a, 5, "parameter passed to testWidget2" );
+ deepEqual( b, 10, "second parameter passed to testWidget2" );
return this._superApply( arguments );
}
});
$.widget( "ui.testWidget3", $.ui.testWidget2, {
method: function( a, b ) {
- same( this, instance, "this is correct in testWidget3" );
- same( a, 5, "parameter passed to testWidget3" );
- same( b, 10, "second parameter passed to testWidget3" );
+ deepEqual( this, instance, "this is correct in testWidget3" );
+ deepEqual( a, 5, "parameter passed to testWidget3" );
+ deepEqual( b, 10, "second parameter passed to testWidget3" );
var ret = this._superApply( arguments );
- same( ret, 15, "super returned value" );
+ deepEqual( ret, 15, "super returned value" );
}
});
qux: [ "quux", "quuux" ]
});
- same( div.testWidget( "option", "x" ), null, "non-existent option" );
- same( div.testWidget( "option", "foo"), "bar", "single option - string" );
- same( div.testWidget( "option", "baz"), 5, "single option - number" );
- same( div.testWidget( "option", "qux"), [ "quux", "quuux" ],
+ deepEqual( div.testWidget( "option", "x" ), null, "non-existent option" );
+ deepEqual( div.testWidget( "option", "foo"), "bar", "single option - string" );
+ deepEqual( div.testWidget( "option", "baz"), 5, "single option - number" );
+ deepEqual( div.testWidget( "option", "qux"), [ "quux", "quuux" ],
"single option - array" );
var options = div.testWidget( "option" );
- same( options, {
+ deepEqual( options, {
create: null,
disabled: false,
foo: "bar",
qux: [ "quux", "quuux" ]
}, "full options hash returned" );
options.foo = "notbar";
- same( div.testWidget( "option", "foo"), "bar",
+ deepEqual( div.testWidget( "option", "foo"), "bar",
"modifying returned options hash does not modify plugin instance" );
});
calls = [];
div.testWidget( "option", "foo", "bar" );
- same( calls, [{ foo: "bar" }], "_setOptions called for single option" );
+ deepEqual( calls, [{ foo: "bar" }], "_setOptions called for single option" );
calls = [];
div.testWidget( "option", {
bar: "qux",
quux: "quuux"
});
- same( calls, [{ bar: "qux", quux: "quuux" }],
+ deepEqual( calls, [{ bar: "qux", quux: "quuux" }],
"_setOptions called with multiple options" );
});
calls = [];
div.testWidget( "option", "foo", "bar" );
- same( calls, [{ key: "foo", val: "bar" }],
+ deepEqual( calls, [{ key: "foo", val: "bar" }],
"_setOption called for single option" );
calls = [];
bar: "qux",
quux: "quuux"
});
- same( calls, [
+ deepEqual( calls, [
{ key: "bar", val: "qux" },
{ key: "quux", val: "quuux" }
], "_setOption called with multiple options" );
function deepOption( from, to, msg ) {
div.data( "testWidget" ).options.foo = from;
$.ui.testWidget.prototype._setOption = function( key, value ) {
- same( key, "foo", msg + ": key" );
- same( value, to, msg + ": value" );
+ deepEqual( key, "foo", msg + ": key" );
+ deepEqual( value, to, msg + ": value" );
};
}
$.widget( "ui.testWidget", {
_create: function() {},
_setOption: function( key, val ) {
- same( key, "disabled", "_setOption called with disabled option" );
- same( val, false, "disabled set to false" );
+ deepEqual( key, "disabled", "_setOption called with disabled option" );
+ deepEqual( val, false, "disabled set to false" );
}
});
$( "<div>" ).testWidget().testWidget( "enable" );
$.widget( "ui.testWidget", {
_create: function() {},
_setOption: function( key, val ) {
- same( key, "disabled", "_setOption called with disabled option" );
- same( val, true, "disabled set to true" );
+ deepEqual( key, "disabled", "_setOption called with disabled option" );
+ deepEqual( val, true, "disabled set to true" );
}
});
$( "<div>" ).testWidget().testWidget( "disable" );
_create: function() {}
});
var div = $( "<div>" ).testWidget();
- same( div[0], div.testWidget( "widget" )[0]);
+ deepEqual( div[0], div.testWidget( "widget" )[0]);
});
test( ".widget() - overriden", function() {
return wrapper;
}
});
- same( wrapper[0], $( "<div>" ).testWidget().testWidget( "widget" )[0] );
+ deepEqual( wrapper[0], $( "<div>" ).testWidget().testWidget( "widget" )[0] );
});
test( "._bind() to element (default)", function() {
});
},
keyup: function( event ) {
- equals( that, this );
- equals( that.element[0], event.currentTarget );
- equals( "keyup", event.type );
+ equal( that, this );
+ equal( that.element[0], event.currentTarget );
+ equal( "keyup", event.type );
},
keydown: function( event ) {
- equals( that, this );
- equals( that.element[0], event.currentTarget );
- equals( "keydown", event.type );
+ equal( that, this );
+ equal( that.element[0], event.currentTarget );
+ equal( "keydown", event.type );
}
});
var widget = $( "<div></div>" )
});
},
keyup: function( event ) {
- equals( that, this );
- equals( that.element.find( "strong" )[0], event.currentTarget );
- equals( "keyup", event.type );
+ equal( that, this );
+ equal( that.element.find( "strong" )[0], event.currentTarget );
+ equal( "keyup", event.type );
},
keydown: function(event) {
- equals( that, this );
- equals( that.element.find( "strong" )[0], event.currentTarget );
- equals( "keydown", event.type );
+ equal( that, this );
+ equal( that.element.find( "strong" )[0], event.currentTarget );
+ equal( "keydown", event.type );
}
});
// trigger events on both widget and descendent to ensure that only descendent receives them
$( "#widget" ).testWidget({
foo: function( event, ui ) {
- same( event.type, "testwidgetfoo", "correct event type in callback" );
- same( ui, {}, "empty ui hash passed" );
+ deepEqual( event.type, "testwidgetfoo", "correct event type in callback" );
+ deepEqual( ui, {}, "empty ui hash passed" );
handlers.push( "callback" );
}
});
$( document ).add( "#widget-wrapper" ).add( "#widget" )
.bind( "testwidgetfoo", function( event, ui ) {
- same( ui, {}, "empty ui hash passed" );
+ deepEqual( ui, {}, "empty ui hash passed" );
handlers.push( this );
});
- same( $( "#widget" ).data( "testWidget" )._trigger( "foo" ), true,
+ deepEqual( $( "#widget" ).data( "testWidget" )._trigger( "foo" ), true,
"_trigger returns true when event is not cancelled" );
- same( handlers, [
+ deepEqual( handlers, [
$( "#widget" )[ 0 ],
$( "#widget-wrapper" )[ 0 ],
document,
ok( true, "event was triggered" );
return false;
});
- same( $( "#widget" ).data( "testWidget" )._trigger( "foo" ), false,
+ deepEqual( $( "#widget" ).data( "testWidget" )._trigger( "foo" ), false,
"_trigger returns false when event is cancelled" );
});
return false;
}
});
- same( $( "#widget" ).data( "testWidget" )._trigger( "foo" ), false,
+ deepEqual( $( "#widget" ).data( "testWidget" )._trigger( "foo" ), false,
"_trigger returns false when callback returns false" );
});
}
};
this._trigger( "foo", originalEvent, ui );
- same( ui, {
+ deepEqual( ui, {
foo: "notbar",
baz: {
qux: 10,
});
$( "#widget" ).bind( "testwidgetfoo", function( event, ui ) {
equal( event.originalEvent, originalEvent, "original event object passed" );
- same( ui, {
+ deepEqual( ui, {
foo: "bar",
baz: {
qux: 5,
});
$( "#widget-wrapper" ).bind( "testwidgetfoo", function( event, ui ) {
equal( event.originalEvent, originalEvent, "original event object passed" );
- same( ui, {
+ deepEqual( ui, {
foo: "notbar",
baz: {
qux: 5,
$( "#widget" ).testWidget({
foo: function( event, ui ) {
equal( event.originalEvent, originalEvent, "original event object passed" );
- same( ui, {
+ deepEqual( ui, {
foo: "notbar",
baz: {
qux: 10,
}
});
$( "#widget" ).bind( "testwidgetfoo", function( event, ui, extra ) {
- same( ui, {
+ deepEqual( ui, {
foo: "bar",
baz: {
qux: 5,
quux: 20
}
}, "event: ui hash passed" );
- same( extra, {
+ deepEqual( extra, {
bar: 5
}, "event: extra argument passed" );
});
$( "#widget" ).testWidget({
foo: function( event, ui, extra ) {
- same( ui, {
+ deepEqual( ui, {
foo: "bar",
baz: {
qux: 5,
quux: 20
}
}, "callback: ui hash passed" );
- same( extra, {
+ deepEqual( extra, {
bar: 5
}, "callback: extra argument passed" );
}
var instance = $.ui.testWidget({
foo: function( event, ui ) {
equal( event.type, "testwidgetfoo", "event object passed to callback" );
- same( ui, { foo: "bar" }, "ui object passed to callback" );
+ deepEqual( ui, { foo: "bar" }, "ui object passed to callback" );
}
});
$( instance ).bind( "testwidgetfoo", function( event, ui ) {
equal( event.type, "testwidgetfoo", "event object passed to event handler" );
- same( ui, { foo: "bar" }, "ui object passed to event handler" );
+ deepEqual( ui, { foo: "bar" }, "ui object passed to event handler" );
});
instance.testEvent();
});