From ddbc6eb4c9a7f1ffdc8171fcb852da8475ba0638 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Fri, 28 Aug 2015 14:49:15 -0700 Subject: [PATCH] test for pop --- tests/ArrayTests.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/ArrayTests.js b/tests/ArrayTests.js index 8f9f5cb7..684776df 100644 --- a/tests/ArrayTests.js +++ b/tests/ArrayTests.js @@ -128,9 +128,31 @@ var ArrayTests = { }); TestCase.assertEqual(array.length, 4); - TestCase.assertThrows(function() { - array.push([1]); + // TestCase.assertThrows(function() { + // 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() { @@ -152,9 +174,9 @@ var ArrayTests = { }); TestCase.assertEqual(array.length, 4); - TestCase.assertThrows(function() { - array.unshift([1]); - }); + // TestCase.assertThrows(function() { + // array.unshift([1]); + // }); }, };