Fix all linting issues inside JS tests

This commit is contained in:
Scott Kyle 2016-05-20 16:33:16 -07:00
parent 846e3b976d
commit af70bb3c63
7 changed files with 33 additions and 26 deletions

View File

@ -14,8 +14,5 @@
"Uint32Array": false,
"Uint8Array": false,
"Uint8ClampedArray": false
},
"rules": {
"no-redeclare": 1
}
}

View File

@ -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);
},
};

View File

@ -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;
});

View File

@ -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: {

View File

@ -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") {

View File

@ -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);
},
};

View File

@ -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;
});