Add test for generic collections
This commit is contained in:
parent
f96e053417
commit
9490b2e48c
4 changed files with 72 additions and 1 deletions
50
test/tests/HopObjectGeneric.js
Normal file
50
test/tests/HopObjectGeneric.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
tests = [
|
||||
'testSize'
|
||||
];
|
||||
|
||||
var org;
|
||||
var size = 16;
|
||||
|
||||
function setup() {
|
||||
org = new Organisation();
|
||||
org.name = "GenericOrg";
|
||||
var i = 0, person;
|
||||
|
||||
function addPerson(collection) {
|
||||
person = new Person();
|
||||
person.name = "GenericPerson " + i.format("00");
|
||||
collection.add(person);
|
||||
i++;
|
||||
}
|
||||
|
||||
// add first half to both collections of transient parent ...
|
||||
while (i < 4)
|
||||
addPerson(org.generic);
|
||||
while (i < 8)
|
||||
addPerson(org.groupedGeneric);
|
||||
root.organisations.add(org);
|
||||
// ... second half to both collections of persistent parent.
|
||||
while (i < 12)
|
||||
addPerson(org.generic);
|
||||
while (i < size)
|
||||
addPerson(org.groupedGeneric);
|
||||
|
||||
res.commit();
|
||||
}
|
||||
|
||||
function testSize() {
|
||||
assertEqual(org.generic.size(), size);
|
||||
org.invalidate();
|
||||
assertEqual(org.generic.size(), size);
|
||||
}
|
||||
|
||||
function cleanup() {
|
||||
var persons = org.generic.list();
|
||||
for each (var person in persons) {
|
||||
if (person.groupname)
|
||||
person.get(0).remove();
|
||||
else
|
||||
person.remove();
|
||||
}
|
||||
org.remove();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue