forked from bitovi/jquerypp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_test.js
More file actions
105 lines (72 loc) · 1.99 KB
/
object_test.js
File metadata and controls
105 lines (72 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
steal('funcunit/qunit','./object',function(){
module("object");
test("same", function(){
ok( $.Object.same({type: "FOLDER"},{type: "FOLDER", count: 5}, {
count: null
}), "count ignored" );
ok( $.Object.same({type: "folder"},{type: "FOLDER"}, {
type: "i"
}), "folder case ignored" );
})
test("subsets", function(){
var res1 = $.Object.subsets({parentId: 5, type: "files"},
[{parentId: 6}, {type: "folders"}, {type: "files"}]);
same(res1,[{type: "files"}])
var res2 = $.Object.subsets({parentId: 5, type: "files"},
[{}, {type: "folders"}, {type: "files"}]);
same(res2,[{},{type: "files"}]);
var res3 = $.Object.subsets({parentId: 5, type: "folders"},
[{parentId: 5},{type: "files"}]);
same(res3,[{parentId: 5}])
});
test("subset compare", function(){
ok( $.Object.subset(
{type: "FOLDER"},
{type: "FOLDER"}),
"equal sets" );
ok( $.Object.subset(
{type: "FOLDER", parentId: 5},
{type: "FOLDER"}),
"sub set" );
ok(! $.Object.subset(
{type: "FOLDER"},
{type: "FOLDER", parentId: 5}),
"wrong way" );
ok(! $.Object.subset(
{type: "FOLDER", parentId: 7},
{type: "FOLDER", parentId: 5}),
"different values" );
ok( $.Object.subset(
{type: "FOLDER", count: 5}, // subset
{type: "FOLDER"},
{count: null} ),
"count ignored" );
ok( $.Object.subset(
{type: "FOLDER", kind: "tree"}, // subset
{type: "FOLDER", foo: true, bar: true },
{foo: null, bar: null} ),
"understands a subset" );
ok( $.Object.subset(
{type: "FOLDER", foo: true, bar: true },
{type: "FOLDER", kind: "tree"}, // subset
{foo: null, bar: null, kind : null} ),
"ignores nulls" );
});
test("searchText", function(){
var item = {
id: 1,
name: "thinger"
},
searchText = {
searchText : "foo"
},
compare = {
searchText : function(items, paramsText, itemr, params){
equals(item,itemr);
equals(searchText, params)
return true;
}
};
ok( $.Object.subset( item, searchText, compare ), "searchText" );
});
});