1
1
test ( "$.widget.extend(Object, Object)" , function ( ) {
2
- expect ( 28 ) ;
2
+ expect ( 26 ) ;
3
3
4
4
var settings = { xnumber1 : 5 , xnumber2 : 7 , xstring1 : "peter" , xstring2 : "pan" } ,
5
5
options = { xnumber2 : 1 , xstring2 : "x" , xxx : "newstring" } ,
@@ -11,83 +11,81 @@ test("$.widget.extend(Object, Object)", function() {
11
11
deep2copy = { foo : { baz : true } , foo2 : document } ,
12
12
deepmerged = { foo : { bar : true , baz : true } , foo2 : document } ,
13
13
arr = [ 1 , 2 , 3 ] ,
14
- nestedarray = { arr : arr } ;
14
+ nestedarray = { arr : arr } ,
15
+ ret ;
15
16
16
17
$ . widget . extend ( settings , options ) ;
17
- same ( settings , merged , "Check if extended: settings must be extended" ) ;
18
- same ( options , optionsCopy , "Check if not modified: options must not be modified" ) ;
19
- $ . widget . extend ( settings , null , options ) ;
20
- same ( settings , merged , "Check if extended: settings must be extended" ) ;
21
- same ( options , optionsCopy , "Check if not modified: options must not be modified" ) ;
18
+ deepEqual ( settings , merged , "Check if extended: settings must be extended" ) ;
19
+ deepEqual ( options , optionsCopy , "Check if not modified: options must not be modified" ) ;
22
20
23
21
$ . widget . extend ( deep1 , deep2 ) ;
24
- same ( deep1 . foo , deepmerged . foo , "Check if foo: settings must be extended" ) ;
25
- same ( deep2 . foo , deep2copy . foo , "Check if not deep2: options must not be modified" ) ;
26
- equals ( deep1 . foo2 , document , "Make sure that a deep clone was not attempted on the document" ) ;
22
+ deepEqual ( deep1 . foo , deepmerged . foo , "Check if foo: settings must be extended" ) ;
23
+ deepEqual ( deep2 . foo , deep2copy . foo , "Check if not deep2: options must not be modified" ) ;
24
+ equal ( deep1 . foo2 , document , "Make sure that a deep clone was not attempted on the document" ) ;
27
25
28
- ok ( $ . widget . extend ( { } , nestedarray ) . arr === arr , "Don't clone arrays" ) ;
26
+ strictEqual ( $ . widget . extend ( { } , nestedarray ) . arr , arr , "Don't clone arrays" ) ;
29
27
ok ( jQuery . isPlainObject ( $ . widget . extend ( { arr : arr } , { arr : { } } ) . arr ) , "Cloned object heve to be an plain object" ) ;
30
28
31
29
var empty = { } ;
32
30
var optionsWithLength = { foo : { length : - 1 } } ;
33
31
$ . widget . extend ( empty , optionsWithLength ) ;
34
- same ( empty . foo , optionsWithLength . foo , "The length property must copy correctly" ) ;
32
+ deepEqual ( empty . foo , optionsWithLength . foo , "The length property must copy correctly" ) ;
35
33
36
34
empty = { } ;
37
35
var optionsWithDate = { foo : { date : new Date } } ;
38
36
$ . widget . extend ( empty , optionsWithDate ) ;
39
- same ( empty . foo , optionsWithDate . foo , "Dates copy correctly" ) ;
37
+ deepEqual ( empty . foo , optionsWithDate . foo , "Dates copy correctly" ) ;
40
38
41
39
var myKlass = function ( ) { } ;
42
40
var customObject = new myKlass ( ) ;
43
41
var optionsWithCustomObject = { foo : { date : customObject } } ;
44
42
empty = { } ;
45
43
$ . widget . extend ( empty , optionsWithCustomObject ) ;
46
- ok ( empty . foo && empty . foo . date === customObject , "Custom objects copy correctly (no methods)" ) ;
44
+ strictEqual ( empty . foo . date , customObject , "Custom objects copy correctly (no methods)" ) ;
47
45
48
46
// Makes the class a little more realistic
49
47
myKlass . prototype = { someMethod : function ( ) { } } ;
50
48
empty = { } ;
51
49
$ . widget . extend ( empty , optionsWithCustomObject ) ;
52
- ok ( empty . foo && empty . foo . date === customObject , "Custom objects copy correctly" ) ;
50
+ strictEqual ( empty . foo . date , customObject , "Custom objects copy correctly" ) ;
53
51
54
- var ret = $ . widget . extend ( { foo : 4 } , { foo : new Number ( 5 ) } ) ;
55
- ok ( ret . foo == 5 , "Wrapped numbers copy correctly" ) ;
52
+ ret = $ . widget . extend ( { foo : 4 } , { foo : new Number ( 5 ) } ) ;
53
+ equal ( ret . foo , 5 , "Wrapped numbers copy correctly" ) ;
56
54
57
55
var nullUndef ;
58
56
nullUndef = $ . widget . extend ( { } , options , { xnumber2 : null } ) ;
59
- ok ( nullUndef . xnumber2 === null , "Check to make sure null values are copied" ) ;
57
+ strictEqual ( nullUndef . xnumber2 , null , "Check to make sure null values are copied" ) ;
60
58
61
59
nullUndef = $ . widget . extend ( { } , options , { xnumber2 : undefined } ) ;
62
- ok ( nullUndef . xnumber2 === options . xnumber2 , "Check to make sure undefined values are not copied" ) ;
60
+ strictEqual ( nullUndef . xnumber2 , options . xnumber2 , "Check to make sure undefined values are not copied" ) ;
63
61
64
62
nullUndef = $ . widget . extend ( { } , options , { xnumber0 : null } ) ;
65
- ok ( nullUndef . xnumber0 === null , "Check to make sure null values are inserted" ) ;
63
+ strictEqual ( nullUndef . xnumber0 , null , "Check to make sure null values are inserted" ) ;
66
64
67
65
// TODO weird test
68
66
/*
69
67
var target = {};
70
68
var recursive = { foo:target, bar:5 };
71
69
$.widget.extend(target, recursive);
72
- same ( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
70
+ deepEqual ( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" );
73
71
*/
74
72
75
- var ret = jQuery . extend ( true , { foo : [ ] } , { foo : [ 0 ] } ) ; // 1907
76
- equals ( ret . foo . length , 1 , "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" ) ;
73
+ ret = jQuery . extend ( true , { foo : [ ] } , { foo : [ 0 ] } ) ; // 1907
74
+ equal ( ret . foo . length , 1 , "Check to make sure a value with coersion 'false' copies over when necessary to fix #1907" ) ;
77
75
78
- var ret = jQuery . extend ( true , { foo : "1,2,3" } , { foo : [ 1 , 2 , 3 ] } ) ;
79
- ok ( typeof ret . foo != "string" , "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" ) ;
76
+ ret = jQuery . extend ( true , { foo : "1,2,3" } , { foo : [ 1 , 2 , 3 ] } ) ;
77
+ notStrictEqual ( typeof ret . foo , "string" , "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" ) ;
80
78
81
- var ret = jQuery . extend ( true , { foo :"bar" } , { foo :null } ) ;
82
- ok ( typeof ret . foo !== "undefined" , "Make sure a null value doesn't crash with deep extend, for #1908" ) ;
79
+ ret = jQuery . extend ( true , { foo :"bar" } , { foo :null } ) ;
80
+ notStrictEqual ( typeof ret . foo , "undefined" , "Make sure a null value doesn't crash with deep extend, for #1908" ) ;
83
81
84
82
var obj = { foo :null } ;
85
83
jQuery . extend ( true , obj , { foo :"notnull" } ) ;
86
- equals ( obj . foo , "notnull" , "Make sure a null value can be overwritten" ) ;
84
+ equal ( obj . foo , "notnull" , "Make sure a null value can be overwritten" ) ;
87
85
88
86
function func ( ) { }
89
87
jQuery . extend ( func , { key : "value" } ) ;
90
- equals ( func . key , "value" , "Verify a function can be extended" ) ;
88
+ equal ( func . key , "value" , "Verify a function can be extended" ) ;
91
89
92
90
var defaults = { xnumber1 : 5 , xnumber2 : 7 , xstring1 : "peter" , xstring2 : "pan" } ,
93
91
defaultsCopy = { xnumber1 : 5 , xnumber2 : 7 , xstring1 : "peter" , xstring2 : "pan" } ,
@@ -98,10 +96,10 @@ test("$.widget.extend(Object, Object)", function() {
98
96
merged2 = { xnumber1 : 5 , xnumber2 : 1 , xstring1 : "peter" , xstring2 : "xx" , xxx : "newstringx" } ;
99
97
100
98
var settings = jQuery . extend ( { } , defaults , options1 , options2 ) ;
101
- same ( settings , merged2 , "Check if extended: settings must be extended" ) ;
102
- same ( defaults , defaultsCopy , "Check if not modified: options1 must not be modified" ) ;
103
- same ( options1 , options1Copy , "Check if not modified: options1 must not be modified" ) ;
104
- same ( options2 , options2Copy , "Check if not modified: options2 must not be modified" ) ;
99
+ deepEqual ( settings , merged2 , "Check if extended: settings must be extended" ) ;
100
+ deepEqual ( defaults , defaultsCopy , "Check if not modified: options1 must not be modified" ) ;
101
+ deepEqual ( options1 , options1Copy , "Check if not modified: options1 must not be modified" ) ;
102
+ deepEqual ( options2 , options2Copy , "Check if not modified: options2 must not be modified" ) ;
105
103
106
104
var input = {
107
105
key : [ 1 , 2 , 3 ]
0 commit comments