mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Add listView async tests
This commit is contained in:
parent
05189361b7
commit
08d124d6b6
@ -86,4 +86,92 @@
|
||||
equal($field.html(), v.label, k + '-> Has correct label');
|
||||
});
|
||||
});
|
||||
|
||||
test('Data loading state', function() {
|
||||
var $listView = listView();
|
||||
|
||||
equal($listView.find('table.body tr.loading').size(), 1, 'Row has loading state');
|
||||
equal($listView.find('table.body tr.loading td.loading.icon').size(), 1, 'Row cell has loading icon');
|
||||
});
|
||||
|
||||
asyncTest('Data provider: basic', function() {
|
||||
expect(3);
|
||||
var $listView = listView({
|
||||
listView: {
|
||||
fields: {
|
||||
fieldA: { label: 'TestFieldA' },
|
||||
fieldB: { label: 'TestFieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({ data: [] });
|
||||
|
||||
ok(true, 'Data provider called');
|
||||
start();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
equal($listView.find('.data-table table.body tbody tr.empty td').size(), 1, 'Body table has empty table row');
|
||||
equal($listView.find('.data-table table.body tbody tr.empty td').html(), 'label.no.data', 'Empty contents notice displayed');
|
||||
});
|
||||
|
||||
asyncTest('Data provider: load data', function() {
|
||||
var $listView = listView({
|
||||
listView: {
|
||||
fields: {
|
||||
fieldA: { label: 'TestFieldA' },
|
||||
fieldB: { label: 'TestFieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: [
|
||||
{ fieldA: 'FieldDataA', fieldB: 'FieldDataB' }
|
||||
]
|
||||
});
|
||||
|
||||
start();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
equal($listView.find('table.body tbody tr').size(), 1, 'Body table has table row');
|
||||
equal($listView.find('table.body tbody tr td').size(), 2, 'Body table has table cells');
|
||||
equal($listView.find('table.body tbody tr td.fieldA > span').html(), 'FieldDataA', 'FieldDataA content present');
|
||||
equal($listView.find('table.body tbody tr td.fieldB > span').html(), 'FieldDataB', 'FieldDataB content present');
|
||||
});
|
||||
|
||||
asyncTest('Data provider: multiple rows of data', function() {
|
||||
var testData = [
|
||||
{ fieldA: 'FieldDataA1', fieldB: 'FieldDataB1' },
|
||||
{ fieldA: 'FieldDataA2', fieldB: 'FieldDataB2' },
|
||||
{ fieldA: 'FieldDataA3', fieldB: 'FieldDataB3' }
|
||||
];
|
||||
|
||||
var $listView = listView({
|
||||
listView: {
|
||||
fields: {
|
||||
fieldA: { label: 'TestFieldA' },
|
||||
fieldB: { label: 'TestFieldB' }
|
||||
},
|
||||
dataProvider: function(args) {
|
||||
args.response.success({
|
||||
data: testData
|
||||
});
|
||||
|
||||
start();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
equal($listView.find('table.body tbody tr').size(), 3, 'Body table has correct # of table rows');
|
||||
|
||||
$(testData).map(function(index, data) {
|
||||
var $tr = $listView.find('table.body tbody tr').filter(function() {
|
||||
return $(this).index() === index;
|
||||
});
|
||||
|
||||
equal($tr.find('td.fieldA > span').html(), 'FieldDataA' + (index + 1), 'FieldDataA' + (index + 1) + ' present');
|
||||
equal($tr.find('td.fieldB > span').html(), 'FieldDataB' + (index + 1), 'FieldDataB' + (index + 1) + ' present');
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user