mirror of
https://github.com/tuxis-ie/nsedit.git
synced 2025-05-24 00:24:07 +03:00
Merge commit 'd21ea7816e
' as 'jquery-ui'
This commit is contained in:
commit
e904a80717
629 changed files with 341074 additions and 0 deletions
26
jquery-ui/tests/unit/widget/all.html
Normal file
26
jquery-ui/tests/unit/widget/all.html
Normal file
|
@ -0,0 +1,26 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Widget Test Suite</title>
|
||||
|
||||
<script src="../../../external/jquery/jquery.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<link rel="stylesheet" href="../qunit-composite.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../qunit-composite.js"></script>
|
||||
<script src="../subsuite.js"></script>
|
||||
|
||||
<script>
|
||||
testAllVersions( "widget" );
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
40
jquery-ui/tests/unit/widget/widget.html
Normal file
40
jquery-ui/tests/unit/widget/widget.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jQuery UI Widget Test Suite</title>
|
||||
|
||||
<script src="../../jquery.js"></script>
|
||||
<link rel="stylesheet" href="../../../external/qunit/qunit.css">
|
||||
<script src="../../../external/qunit/qunit.js"></script>
|
||||
<script src="../../../external/jquery-simulate/jquery.simulate.js"></script>
|
||||
<script src="../testsuite.js"></script>
|
||||
<script>
|
||||
TestHelpers.loadResources({
|
||||
css: [ "core" ],
|
||||
js: [
|
||||
"ui/widget.js"
|
||||
]
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="widget_core.js"></script>
|
||||
<script src="widget_extend.js"></script>
|
||||
<script src="widget_animation.js"></script>
|
||||
|
||||
<script src="../swarminject.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture">
|
||||
|
||||
<div id="widget-wrapper">
|
||||
<div id="widget">
|
||||
<div>...</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
257
jquery-ui/tests/unit/widget/widget_animation.js
vendored
Normal file
257
jquery-ui/tests/unit/widget/widget_animation.js
vendored
Normal file
|
@ -0,0 +1,257 @@
|
|||
|
||||
module( "widget animation", (function() {
|
||||
var show = $.fn.show,
|
||||
fadeIn = $.fn.fadeIn,
|
||||
slideDown = $.fn.slideDown;
|
||||
return {
|
||||
setup: function() {
|
||||
$.widget( "ui.testWidget", {
|
||||
_create: function() {
|
||||
this.element.hide();
|
||||
},
|
||||
show: function( fn ) {
|
||||
this._show( this.element, this.options.show, fn );
|
||||
}
|
||||
});
|
||||
$.effects = { effect: { testEffect: $.noop } };
|
||||
},
|
||||
teardown: function() {
|
||||
delete $.ui.testWidget;
|
||||
delete $.effects.effect.testEffect;
|
||||
$.fn.show = show;
|
||||
$.fn.fadeIn = fadeIn;
|
||||
$.fn.slideDown = slideDown;
|
||||
}
|
||||
};
|
||||
}()));
|
||||
|
||||
asyncTest( "show: null", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#widget" ).testWidget(),
|
||||
hasRun = false;
|
||||
$.fn.show = function() {
|
||||
ok( true, "show called" );
|
||||
equal( arguments.length, 0, "no args passed to show" );
|
||||
};
|
||||
|
||||
element
|
||||
.delay( 50 )
|
||||
.queue(function( next ) {
|
||||
ok( !hasRun, "queue before show" );
|
||||
next();
|
||||
})
|
||||
.testWidget( "show", function() {
|
||||
hasRun = true;
|
||||
})
|
||||
.queue(function( next ) {
|
||||
ok( hasRun, "queue after show" );
|
||||
start();
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "show: true", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#widget" ).testWidget({
|
||||
show: true
|
||||
}),
|
||||
hasRun = false;
|
||||
$.fn.fadeIn = function( duration, easing, complete ) {
|
||||
return this.queue(function( next ) {
|
||||
strictEqual( duration, undefined, "duration" );
|
||||
strictEqual( easing, undefined, "easing" );
|
||||
complete();
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
element
|
||||
.delay( 50 )
|
||||
.queue(function( next ) {
|
||||
ok( !hasRun, "queue before show" );
|
||||
next();
|
||||
})
|
||||
.testWidget( "show", function() {
|
||||
hasRun = true;
|
||||
})
|
||||
.queue(function( next ) {
|
||||
ok( hasRun, "queue after show" );
|
||||
start();
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "show: number", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#widget" ).testWidget({
|
||||
show: 123
|
||||
}),
|
||||
hasRun = false;
|
||||
$.fn.fadeIn = function( duration, easing, complete ) {
|
||||
return this.queue(function( next ) {
|
||||
strictEqual( duration, 123, "duration" );
|
||||
strictEqual( easing, undefined, "easing" );
|
||||
complete();
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
element
|
||||
.delay( 50 )
|
||||
.queue(function( next ) {
|
||||
ok( !hasRun, "queue before show" );
|
||||
next();
|
||||
})
|
||||
.testWidget( "show", function() {
|
||||
hasRun = true;
|
||||
})
|
||||
.queue(function( next ) {
|
||||
ok( hasRun, "queue after show" );
|
||||
start();
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "show: core animation", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#widget" ).testWidget({
|
||||
show: "slideDown"
|
||||
}),
|
||||
hasRun = false;
|
||||
$.fn.slideDown = function( duration, easing, complete ) {
|
||||
return this.queue(function( next ) {
|
||||
strictEqual( duration, undefined, "duration" );
|
||||
strictEqual( easing, undefined, "easing" );
|
||||
complete();
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
element
|
||||
.delay( 50 )
|
||||
.queue(function( next ) {
|
||||
ok( !hasRun, "queue before show" );
|
||||
next();
|
||||
})
|
||||
.testWidget( "show", function() {
|
||||
hasRun = true;
|
||||
})
|
||||
.queue(function( next ) {
|
||||
ok( hasRun, "queue after show" );
|
||||
start();
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "show: effect", function() {
|
||||
expect( 5 );
|
||||
|
||||
var element = $( "#widget" ).testWidget({
|
||||
show: "testEffect"
|
||||
}),
|
||||
hasRun = false;
|
||||
$.fn.show = function( options ) {
|
||||
return this.queue(function( next ) {
|
||||
equal( options.effect, "testEffect", "effect" );
|
||||
ok( !("duration" in options), "duration" );
|
||||
ok( !("easing" in options), "easing" );
|
||||
options.complete();
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
element
|
||||
.delay( 50 )
|
||||
.queue(function( next ) {
|
||||
ok( !hasRun, "queue before show" );
|
||||
next();
|
||||
})
|
||||
.testWidget( "show", function() {
|
||||
hasRun = true;
|
||||
})
|
||||
.queue(function( next ) {
|
||||
ok( hasRun, "queue after show" );
|
||||
start();
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "show: object(core animation)", function() {
|
||||
expect( 4 );
|
||||
|
||||
var element = $( "#widget" ).testWidget({
|
||||
show: {
|
||||
effect: "slideDown",
|
||||
duration: 123,
|
||||
easing: "testEasing"
|
||||
}
|
||||
}),
|
||||
hasRun = false;
|
||||
$.fn.slideDown = function( duration, easing, complete ) {
|
||||
return this.queue(function( next ) {
|
||||
equal( duration, 123, "duration" );
|
||||
equal( easing, "testEasing", "easing" );
|
||||
complete();
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
element
|
||||
.delay( 50 )
|
||||
.queue(function( next ) {
|
||||
ok( !hasRun, "queue before show" );
|
||||
next();
|
||||
})
|
||||
.testWidget( "show", function() {
|
||||
hasRun = true;
|
||||
})
|
||||
.queue(function( next ) {
|
||||
ok( hasRun, "queue after show" );
|
||||
start();
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
asyncTest( "show: object(effect)", function() {
|
||||
expect( 3 );
|
||||
|
||||
var element = $( "#widget" ).testWidget({
|
||||
show: {
|
||||
effect: "testEffect",
|
||||
duration: 123,
|
||||
easing: "testEasing"
|
||||
}
|
||||
}),
|
||||
hasRun = false;
|
||||
$.fn.show = function( options ) {
|
||||
return this.queue(function( next ) {
|
||||
deepEqual( options, {
|
||||
effect: "testEffect",
|
||||
duration: 123,
|
||||
easing: "testEasing",
|
||||
complete: options.complete
|
||||
});
|
||||
options.complete();
|
||||
next();
|
||||
});
|
||||
};
|
||||
|
||||
element
|
||||
.delay( 50 )
|
||||
.queue(function( next ) {
|
||||
ok( !hasRun, "queue before show" );
|
||||
next();
|
||||
})
|
||||
.testWidget( "show", function() {
|
||||
hasRun = true;
|
||||
})
|
||||
.queue(function( next ) {
|
||||
ok( hasRun, "queue after show" );
|
||||
start();
|
||||
next();
|
||||
});
|
||||
});
|
1507
jquery-ui/tests/unit/widget/widget_core.js
vendored
Normal file
1507
jquery-ui/tests/unit/widget/widget_core.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
105
jquery-ui/tests/unit/widget/widget_extend.js
vendored
Normal file
105
jquery-ui/tests/unit/widget/widget_extend.js
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
test( "$.widget.extend()", function() {
|
||||
expect( 27 );
|
||||
|
||||
var ret, empty, optionsWithLength, optionsWithDate, myKlass, customObject, optionsWithCustomObject, nullUndef,
|
||||
target, recursive, obj, input, output,
|
||||
settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
||||
options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
||||
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
||||
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" },
|
||||
deep1 = { foo: { bar: true } },
|
||||
deep2 = { foo: { baz: true }, foo2: document },
|
||||
deep2copy = { foo: { baz: true }, foo2: document },
|
||||
deepmerged = { foo: { bar: true, baz: true }, foo2: document },
|
||||
arr = [1, 2, 3],
|
||||
nestedarray = { arr: arr },
|
||||
defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
||||
defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
|
||||
options1 = { xnumber2: 1, xstring2: "x" },
|
||||
options1Copy = { xnumber2: 1, xstring2: "x" },
|
||||
options2 = { xstring2: "xx", xxx: "newstringx" },
|
||||
options2Copy = { xstring2: "xx", xxx: "newstringx" },
|
||||
merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
|
||||
|
||||
$.widget.extend( settings, options );
|
||||
deepEqual( settings, merged, "Check if extended: settings must be extended" );
|
||||
deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" );
|
||||
|
||||
$.widget.extend( deep1, deep2 );
|
||||
deepEqual( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" );
|
||||
deepEqual( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" );
|
||||
equal( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" );
|
||||
|
||||
strictEqual( $.widget.extend({}, nestedarray).arr, arr, "Don't clone arrays" );
|
||||
ok( $.isPlainObject( $.widget.extend({ arr: arr }, { arr: {} }).arr ), "Cloned object heve to be an plain object" );
|
||||
|
||||
empty = {};
|
||||
optionsWithLength = { foo: { length: -1 } };
|
||||
$.widget.extend( empty, optionsWithLength );
|
||||
deepEqual( empty.foo, optionsWithLength.foo, "The length property must copy correctly" );
|
||||
|
||||
empty = {};
|
||||
optionsWithDate = { foo: { date: new Date() } };
|
||||
$.widget.extend( empty, optionsWithDate );
|
||||
deepEqual( empty.foo, optionsWithDate.foo, "Dates copy correctly" );
|
||||
|
||||
myKlass = function() {};
|
||||
customObject = new myKlass();
|
||||
optionsWithCustomObject = { foo: { date: customObject } };
|
||||
empty = {};
|
||||
$.widget.extend( empty, optionsWithCustomObject );
|
||||
strictEqual( empty.foo.date, customObject, "Custom objects copy correctly (no methods)" );
|
||||
|
||||
// Makes the class a little more realistic
|
||||
myKlass.prototype = { someMethod: function(){} };
|
||||
empty = {};
|
||||
$.widget.extend( empty, optionsWithCustomObject );
|
||||
strictEqual( empty.foo.date, customObject, "Custom objects copy correctly" );
|
||||
|
||||
ret = $.widget.extend({ foo: 4 }, { foo: Number(5) } );
|
||||
equal( ret.foo, 5, "Wrapped numbers copy correctly" );
|
||||
|
||||
nullUndef = $.widget.extend( {}, options, { xnumber2: null } );
|
||||
strictEqual( nullUndef.xnumber2, null, "Check to make sure null values are copied");
|
||||
|
||||
nullUndef = $.widget.extend( {}, options, { xnumber2: undefined } );
|
||||
strictEqual( nullUndef.xnumber2, options.xnumber2, "Check to make sure undefined values are not copied");
|
||||
|
||||
nullUndef = $.widget.extend( {}, options, { xnumber0: null } );
|
||||
strictEqual( nullUndef.xnumber0, null, "Check to make sure null values are inserted");
|
||||
|
||||
target = {};
|
||||
recursive = { foo:target, bar:5 };
|
||||
$.widget.extend( target, recursive );
|
||||
deepEqual( target, { foo: {}, bar: 5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
|
||||
|
||||
ret = $.widget.extend( { foo: [] }, { foo: [0] } ); // 1907
|
||||
equal( ret.foo.length, 1, "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" );
|
||||
|
||||
ret = $.widget.extend( { foo: "1,2,3" }, { foo: [ 1, 2, 3 ] } );
|
||||
deepEqual( ret.foo, [ 1, 2, 3 ], "Properly extend a string to array." );
|
||||
|
||||
ret = $.widget.extend( { foo: "1,2,3" }, { foo: { to: "object" } } );
|
||||
deepEqual( ret.foo, { to: "object" }, "Properly extend a string to object." );
|
||||
|
||||
ret = $.widget.extend( { foo: "bar" }, { foo: null } );
|
||||
strictEqual( ret.foo, null, "Make sure a null value doesn't crash with deep extend, for #1908" );
|
||||
|
||||
obj = { foo: null };
|
||||
$.widget.extend( obj, { foo:"notnull" } );
|
||||
equal( obj.foo, "notnull", "Make sure a null value can be overwritten" );
|
||||
|
||||
settings = $.widget.extend( {}, defaults, options1, options2 );
|
||||
deepEqual( settings, merged2, "Check if extended: settings must be extended" );
|
||||
deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
|
||||
deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" );
|
||||
deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" );
|
||||
|
||||
input = {
|
||||
key: [ 1, 2, 3 ]
|
||||
};
|
||||
output = $.widget.extend( {}, input );
|
||||
deepEqual( input, output, "don't clone arrays" );
|
||||
input.key[0] = 10;
|
||||
deepEqual( input, output, "don't clone arrays" );
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue