-
Notifications
You must be signed in to change notification settings - Fork 351
Expand file tree
/
Copy pathtests-internal.js
More file actions
204 lines (173 loc) · 4.41 KB
/
tests-internal.js
File metadata and controls
204 lines (173 loc) · 4.41 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*jshint -W024 */
/*jshint -W117 */
module("internal functions", {
setup: function ()
{
$("#qunit-fixture").html("<table id=\"test\"><thead><tr><th data-column-id=\"id\"></th></tr></thead><tfoot><tr><td></td></tr></tfoot></table>");
},
teardown: function ()
{
$("#qunit-fixture").empty();
}
});
test("findFooterAndHeaderItems test", 1, function ()
{
// given
var instance = {
footer: $("#test > tfoot"),
header: $("#test > thead")
};
var selector = "tr";
// when
var result = findFooterAndHeaderItems.call(instance, selector);
// then
equal(result.length, 2, "Found two elements as expected");
});
test("findFooterAndHeaderItems test (footer is null)", 1, function ()
{
// given
var instance = {
footer: null,
header: $("#test > thead")
};
var selector = "tr";
// when
var result = findFooterAndHeaderItems.call(instance, selector);
// then
equal(result.length, 1, "Found one element as expected");
});
test("findFooterAndHeaderItems test (header is null)", 1, function ()
{
// given
var instance = {
footer: $("#test > tfoot"),
header: null
};
var selector = "tr";
// when
var result = findFooterAndHeaderItems.call(instance, selector);
// then
equal(result.length, 1, "Found one element as expected");
});
test("findFooterAndHeaderItems test (footer and header is string empty)", 2, function ()
{
// given
var instance = {
footer: "",
header: ""
};
var selector = "tr";
// when
var result = findFooterAndHeaderItems.call(instance, selector);
// then
equal(result.length, 0, "Foundd one element as expecte");
ok(result.find, "Got an empty jQuery array as expected");
});
test("findFooterAndHeaderItems test (footer and header is null)", 2, function ()
{
// given
var instance = {
footer: null,
header: null
};
var selector = "tr";
// when
var result = findFooterAndHeaderItems.call(instance, selector);
// then
equal(result.length, 0, "Found no elements as expected");
ok(result.find, "Got an empty jQuery array as expected");
});
test("getRequest post function test", 1, function ()
{
// given
var instance = {
options: {
post: function()
{
return {
id: "test"
};
},
requestHandler: function (request) { return request; }
},
current: 1,
rowCount: 5,
sortDictionary: [],
searchPhrase: ""
},
expected = {
current: 1,
id: "test",
rowCount: 5,
sort: [],
searchPhrase: ""
};
// when
var result = getRequest.call(instance);
// then
propEqual(result, expected, "Valid request object");
});
test("getRequest post object test", 1, function() {
// given
var instance = {
options: {
post: {
id: "test"
},
requestHandler: function (request) { return request; }
},
current: 1,
rowCount: 5,
sortDictionary: [],
searchPhrase: ""
},
expected = {
current: 1,
id: "test",
rowCount: 5,
sort: [],
searchPhrase: ""
};
// when
var result = getRequest.call(instance);
// then
propEqual(result, expected, "Valid request object");
});
test("getCssSelector test", 1, function ()
{
// given
var classNames = " itallic bold normal ";
// when
var result = getCssSelector(classNames);
// then
equal(result, ".itallic.bold.normal", "Valid css selector");
});
test("getUrl function test", 1, function ()
{
// given
var instance = {
options: {
url: function()
{
return "url/test/1";
}
}
};
// when
var result = getUrl.call(instance);
// then
equal(result, "url/test/1", "Valid URL");
});
test("getUrl string test", 1, function ()
{
// given
var instance = {
options: {
url: "url/test/1"
}
};
// when
var result = getUrl.call(instance);
// then
equal(result, "url/test/1", "Valid URL");
});