diff --git a/tests/js/.eslintrc.json b/tests/js/.eslintrc.json index fd485029..acc84647 100644 --- a/tests/js/.eslintrc.json +++ b/tests/js/.eslintrc.json @@ -14,8 +14,5 @@ "Uint32Array": false, "Uint8Array": false, "Uint8ClampedArray": false - }, - "rules": { - "no-redeclare": 1 } } diff --git a/tests/js/encryption-tests.js b/tests/js/encryption-tests.js index c4e5aa96..df531a33 100644 --- a/tests/js/encryption-tests.js +++ b/tests/js/encryption-tests.js @@ -53,7 +53,7 @@ module.exports = { }); // test can reopen with original key - var realm = new Realm({schema: [Schemas.TestObject], encryptionKey: key}); + realm = new Realm({schema: [Schemas.TestObject], encryptionKey: key}); TestCase.assertEqual(realm.objects('TestObject').length, 1); }, }; diff --git a/tests/js/list-tests.js b/tests/js/list-tests.js index ebe952cc..262fe412 100644 --- a/tests/js/list-tests.js +++ b/tests/js/list-tests.js @@ -526,7 +526,7 @@ module.exports = { list = object.list; }); - var names = function(results, prop) { + var names = function(results) { return results.map(function(object) { return object.name; }); diff --git a/tests/js/migration-tests.js b/tests/js/migration-tests.js index 64d13625..017ec45e 100644 --- a/tests/js/migration-tests.js +++ b/tests/js/migration-tests.js @@ -81,7 +81,7 @@ module.exports = { }); realm.close(); - var realm = new Realm({ + realm = new Realm({ schema: [{ name: 'TestObject', properties: { @@ -129,7 +129,7 @@ module.exports = { }]}); realm.close(); - var realm = new Realm({ + realm = new Realm({ schema: [{ name: 'TestObject', properties: { diff --git a/tests/js/query-tests.js b/tests/js/query-tests.js index ff01d048..9dea5cea 100644 --- a/tests/js/query-tests.js +++ b/tests/js/query-tests.js @@ -21,7 +21,6 @@ var Realm = require('realm'); var TestCase = require('./asserts'); -var schemas = require('./schemas'); var testCases = require('./query-tests.json'); var typeConverters = {}; @@ -76,18 +75,24 @@ function runQuerySuite(suite) { for (var index in suite.tests) { var test = suite.tests[index]; + var type; + var args; + var results; + if (test[0] == "QueryCount") { - var type = test[2]; - var args = getArgs(3); - var objects = realm.objects(type); - var length = objects.filtered.apply(objects, args).length; + type = test[2]; + args = getArgs(3); + results = realm.objects(type); + + var length = results.filtered.apply(results, args).length; TestCase.assertEqual(test[1], length, "Query '" + args[0] + "' on type '" + type + "' expected " + test[1] + " results, got " + length); } else if (test[0] == "ObjectSet") { - var type = test[2]; - var args = getArgs(3); - var objects = realm.objects(type); - var results = objects.filtered.apply(objects, args); + type = test[2]; + args = getArgs(3); + results = realm.objects(type); + results = results.filtered.apply(results, args); + TestCase.assertEqual(test[1].length, results.length, "Query '" + args[0] + "' on type '" + type+ "' expected " + test[1].length + " results, got " + results.length); var objSchema = suite.schema.find(function(el) { return el.name == type }); @@ -101,11 +106,12 @@ function runQuerySuite(suite) { })); } else if (test[0] == "QueryThrows") { - var type = test[1]; - var args = getArgs(2); - var objects = realm.objects(type); + type = test[1]; + args = getArgs(2); + results = realm.objects(type); + TestCase.assertThrows(function() { - objects.filtered.apply(objects, args); + results.filtered.apply(results, args); }, "Expected exception not thrown for query: " + JSON.stringify(args)); } else if (test[0] != "Disabled") { diff --git a/tests/js/realm-tests.js b/tests/js/realm-tests.js index 77d372df..628adfde 100644 --- a/tests/js/realm-tests.js +++ b/tests/js/realm-tests.js @@ -159,13 +159,16 @@ module.exports = { TestCase.assertEqual(Realm.schemaVersion(Realm.defaultPath), -1); var realm = new Realm({schema: []}); + TestCase.assertEqual(realm.schemaVersion, 0); TestCase.assertEqual(Realm.schemaVersion(Realm.defaultPath), 0); realm = new Realm({schema: [], schemaVersion: 2, path: 'another.realm'}); + TestCase.assertEqual(realm.schemaVersion, 2); TestCase.assertEqual(Realm.schemaVersion('another.realm'), 2); var encryptionKey = new Int8Array(64); realm = new Realm({schema: [], schemaVersion: 3, path: 'encrypted.realm', encryptionKey: encryptionKey}); + TestCase.assertEqual(realm.schemaVersion, 3); TestCase.assertEqual(Realm.schemaVersion('encrypted.realm', encryptionKey), 3); TestCase.assertThrows(function() { @@ -651,7 +654,7 @@ module.exports = { TestCase.assertEqual(notificationName, 'change'); var secondNotificationCount = 0; - function secondNotification(realm, name) { + function secondNotification() { secondNotificationCount++; } @@ -749,7 +752,7 @@ module.exports = { // copy should not overwrite existing files Realm.copyBundledRealmFiles(); - var realm = new Realm({path: 'dates-v5.realm', schema: [schemas.DateObject]}); + realm = new Realm({path: 'dates-v5.realm', schema: [schemas.DateObject]}); TestCase.assertEqual(realm.objects('Date')[0].currentDate.getTime(), 1); }, }; diff --git a/tests/js/results-tests.js b/tests/js/results-tests.js index e36f8f6d..24b3822f 100644 --- a/tests/js/results-tests.js +++ b/tests/js/results-tests.js @@ -99,15 +99,16 @@ module.exports = { testResultsInvalidObjectType: function() { var realm = new Realm({schema: [schemas.TestObject]}); TestCase.assertThrows(function() { - var objects = realm.objects('NotTestObject'); + realm.objects('NotTestObject'); }); }, testResultsEnumerate: function() { var realm = new Realm({schema: [schemas.TestObject]}); var objects = realm.objects('TestObject'); + var index; - for (var index in objects) { + for (index in objects) { TestCase.assertTrue(false, "No objects should have been enumerated"); } @@ -118,7 +119,7 @@ module.exports = { var count = 0; var keys = Object.keys(objects); - for (var index in objects) { + for (index in objects) { TestCase.assertEqual(count++, +index); TestCase.assertEqual(keys[index], index); } @@ -184,7 +185,7 @@ module.exports = { realm.create('IntPrimaryObject', {primaryCol: 0, valueCol: 'c'}); }); - var primaries = function(results, prop) { + var primaries = function(results) { return results.map(function(object) { return object.primaryCol; });