1 | // FIXME remove this once updated to jQuery core 1.3.3
|
---|
2 | var hasDuplicate = false;
|
---|
3 |
|
---|
4 | function testWidgetDefaults(widget, defaults) {
|
---|
5 | var pluginDefaults = $.extend({},
|
---|
6 | $.ui[widget].prototype.options
|
---|
7 | );
|
---|
8 |
|
---|
9 | // ensure that all defaults have the correct value
|
---|
10 | test('defined defaults', function() {
|
---|
11 | $.each(defaults, function(key, val) {
|
---|
12 | if ($.isFunction(val)) {
|
---|
13 | ok(val !== undefined, key);
|
---|
14 | return;
|
---|
15 | }
|
---|
16 | same(pluginDefaults[key], val, key);
|
---|
17 | });
|
---|
18 | });
|
---|
19 |
|
---|
20 | // ensure that all defaults were tested
|
---|
21 | test('tested defaults', function() {
|
---|
22 | $.each(pluginDefaults, function(key, val) {
|
---|
23 | ok(key in defaults, key);
|
---|
24 | });
|
---|
25 | });
|
---|
26 | }
|
---|
27 |
|
---|
28 | function testWidgetOverrides(widget) {
|
---|
29 | test('$.widget overrides', function() {
|
---|
30 | $.each(['_widgetInit', 'option', '_trigger'], function(i, method) {
|
---|
31 | ok($.Widget.prototype[method] == $.ui[widget].prototype[method],
|
---|
32 | 'should not override ' + method);
|
---|
33 | });
|
---|
34 | });
|
---|
35 | }
|
---|
36 |
|
---|
37 | function commonWidgetTests(widget, settings) {
|
---|
38 | module(widget + ": common widget");
|
---|
39 |
|
---|
40 | testWidgetDefaults(widget, settings.defaults);
|
---|
41 | testWidgetOverrides(widget);
|
---|
42 | }
|
---|
43 |
|
---|
44 | // load testswarm agent
|
---|
45 | (function() {
|
---|
46 | var url = window.location.search;
|
---|
47 | url = decodeURIComponent( url.slice( url.indexOf("swarmURL=") + 9 ) );
|
---|
48 | if ( !url || url.indexOf("http") !== 0 ) {
|
---|
49 | return;
|
---|
50 | }
|
---|
51 | document.write("<scr" + "ipt src='http://testswarm.com/js/inject.js?" + (new Date).getTime() + "'></scr" + "ipt>");
|
---|
52 | })();
|
---|