test for pop

This commit is contained in:
Ari Lazier 2015-08-28 14:49:15 -07:00
parent bd39239f00
commit ddbc6eb4c9
1 changed files with 27 additions and 5 deletions

View File

@ -128,9 +128,31 @@ var ArrayTests = {
}); });
TestCase.assertEqual(array.length, 4); TestCase.assertEqual(array.length, 4);
TestCase.assertThrows(function() { // TestCase.assertThrows(function() {
array.push([1]); // array.push([1]);
// });
},
testPop: function() {
var realm = new Realm({schema: [LinkTypesObjectSchema, TestObjectSchema]});
var array;
realm.write(function() {
var obj = realm.create('LinkTypesObject', [[1], [2], [[3]]]);
array = obj.arrayCol;
TestCase.assertEqual(array.pop().doubleCol, 3);
TestCase.assertEqual(array.length, 0);
TestCase.assertEqual(array.pop(), undefined);
TestCase.assertThrows(function() {
array.pop(1);
});
}); });
// TestCase.assertThrows(function() {
// array.pop();
// });
}, },
testUnshift: function() { testUnshift: function() {
@ -152,9 +174,9 @@ var ArrayTests = {
}); });
TestCase.assertEqual(array.length, 4); TestCase.assertEqual(array.length, 4);
TestCase.assertThrows(function() { // TestCase.assertThrows(function() {
array.unshift([1]); // array.unshift([1]);
}); // });
}, },
}; };