Skip to content

Commit ebcf6a1

Browse files
committed
List view: tests for field pre-filter
1 parent 16a9171 commit ebcf6a1

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

ui/tests/test.widget.listView.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
},
105105
dataProvider: function(args) {
106106
args.response.success({ data: [] });
107-
107+
108108
ok(true, 'Data provider called');
109109
start();
110110
}
@@ -128,7 +128,7 @@
128128
{ fieldA: 'FieldDataA', fieldB: 'FieldDataB' }
129129
]
130130
});
131-
131+
132132
start();
133133
}
134134
}
@@ -146,7 +146,7 @@
146146
{ fieldA: 'FieldDataA2', fieldB: 'FieldDataB2' },
147147
{ fieldA: 'FieldDataA3', fieldB: 'FieldDataB3' }
148148
];
149-
149+
150150
var $listView = listView({
151151
listView: {
152152
fields: {
@@ -157,7 +157,7 @@
157157
args.response.success({
158158
data: testData
159159
});
160-
160+
161161
start();
162162
}
163163
}
@@ -169,9 +169,37 @@
169169
var $tr = $listView.find('table.body tbody tr').filter(function() {
170170
return $(this).index() === index;
171171
});
172-
172+
173173
equal($tr.find('td.fieldA > span').html(), 'FieldDataA' + (index + 1), 'FieldDataA' + (index + 1) + ' present');
174174
equal($tr.find('td.fieldB > span').html(), 'FieldDataB' + (index + 1), 'FieldDataB' + (index + 1) + ' present');
175175
});
176176
});
177+
178+
test('Field pre-filter', function() {
179+
var $listView = listView({
180+
listView: {
181+
fields: {
182+
fieldA: { label: 'TestFieldA' },
183+
fieldB: { label: 'TestFieldB' },
184+
fieldHidden: { label: 'TestFieldHidden' }
185+
},
186+
preFilter: function(args) {
187+
return ['fieldHidden'];
188+
},
189+
dataProvider: function(args) {
190+
args.response.success({
191+
data: [
192+
{ fieldA: 'FieldDataA', fieldB: 'FieldDataB', fieldHidden: 'FieldDataHidden' }
193+
]
194+
});
195+
196+
start();
197+
}
198+
}
199+
});
200+
201+
equal($listView.find('table tr th').size(), 2, 'Correct number of header columns present');
202+
equal($listView.find('table.body tbody tr td').size(), 2, 'Correct number of data body columns present');
203+
ok(!$listView.find('table.body tbody td.fieldHidden').size(), 'Hidden field not present');
204+
});
177205
}());

0 commit comments

Comments
 (0)