From 4735a91f8cc68b7ae5695d7f37634b66f7826b11 Mon Sep 17 00:00:00 2001 From: Ari Lazier Date: Fri, 8 Jan 2016 16:33:53 -0800 Subject: [PATCH] run tests --- .../com/reacttests/RealmReactAndroid.java | 3 ++ src/android/platform.cpp | 2 +- tests/lib/ObjectTests.js | 6 ++- tests/react-test-app/index.android.js | 41 +++++++++++++++++-- tests/react-test-app/package.json | 4 +- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/react-native/android/app/src/main/java/com/reacttests/RealmReactAndroid.java b/react-native/android/app/src/main/java/com/reacttests/RealmReactAndroid.java index 65feacd7..c5f3efd7 100644 --- a/react-native/android/app/src/main/java/com/reacttests/RealmReactAndroid.java +++ b/react-native/android/app/src/main/java/com/reacttests/RealmReactAndroid.java @@ -36,6 +36,9 @@ public class RealmReactAndroid extends ReactContextBaseJavaModule { final Map constants = new HashMap<>(); constants.put(DURATION_SHORT_KEY, Toast.LENGTH_SHORT); constants.put(DURATION_LONG_KEY, Toast.LENGTH_LONG); + + Log.w("RealmReactAndroid", injectRealmJsContext()); + return constants; } diff --git a/src/android/platform.cpp b/src/android/platform.cpp index 0e665750..2952643f 100644 --- a/src/android/platform.cpp +++ b/src/android/platform.cpp @@ -9,7 +9,7 @@ namespace realm { std::string default_realm_file_directory() { - return std::string(""); + return std::string("/data/data/com.demo/files/"); } void ensure_directory_exists_for_file(const std::string &fileName) diff --git a/tests/lib/ObjectTests.js b/tests/lib/ObjectTests.js index 92e1b830..53861f8f 100644 --- a/tests/lib/ObjectTests.js +++ b/tests/lib/ObjectTests.js @@ -163,13 +163,15 @@ module.exports = BaseTest.extend({ realm.write(function() { obj = realm.create('NullableBasicTypesObject', basicTypesValues); obj1 = realm.create('NullableBasicTypesObject', basicTypesValues); - for (var prop of schemas.NullableBasicTypes.properties) { + for (var index in schemas.NullableBasicTypes.properties) { + var prop = schemas.NullableBasicTypes.properties[index]; obj[prop.name] = null; obj1[prop.name] = undefined; } }); - for (var prop of schemas.NullableBasicTypes.properties) { + for (var index in schemas.NullableBasicTypes.properties) { + var prop = schemas.NullableBasicTypes.properties[index]; TestCase.assertEqual(obj[prop.name], null); TestCase.assertEqual(obj1[prop.name], null); } diff --git a/tests/react-test-app/index.android.js b/tests/react-test-app/index.android.js index cacf6ff8..6b10a650 100644 --- a/tests/react-test-app/index.android.js +++ b/tests/react-test-app/index.android.js @@ -17,13 +17,48 @@ var RealmReactAndroid = require('NativeModules').RealmReactAndroid; var Realm = require('realm'); var RealmTests = require('realm-tests'); +function runTests() { + RealmTests.ObjectTests.testNullableBasicTypesPropertySetters(); + let testNames = RealmTests.getTestNames(); + + for (let suiteName in testNames) { + let testSuite = RealmTests[suiteName]; + + console.log('Starting ' + suiteName); + + var suiteTestNames = testNames[suiteName]; + for (var index in suiteTestNames) { + var testName = suiteTestNames[index]; + console.log('Starting ' + testName); + + if (testSuite.beforeEach) { + testSuite.beforeEach(); + } + + try { + testSuite[testName](); + console.log('+ ' + testName); + } + catch (e) { + console.log('- ' + testName); + console.warn(e.message); + } + finally { + if (testSuite.afterEach) { + testSuite.afterEach(); + } + } + } + } +} + var Demo = React.createClass({ render: function() { return ( - - Trying to inject Realm JS Context - + + Tap to Run Tests + ); } diff --git a/tests/react-test-app/package.json b/tests/react-test-app/package.json index ac5bd0d9..961eb71b 100644 --- a/tests/react-test-app/package.json +++ b/tests/react-test-app/package.json @@ -6,8 +6,8 @@ "start": "react-native start" }, "dependencies": { - "react-native": "^0.16.0", - "realm": "file:../..", + "react-native": "^0.18.0-rc", + "realm": "file:../../lib", "realm-tests": "file:../lib" } }