From 88352721f7b98484eec9a0d6686e088742f310ad Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Thu, 8 Oct 2015 16:19:19 -0700 Subject: [PATCH] Make all tests explicitly require realm module --- tests/ArrayTests.js | 1 + tests/ObjectTests.js | 1 + tests/RealmJSTests.mm | 3 +++ tests/RealmTests.js | 1 + tests/ResultsTests.js | 1 + tests/package.json | 5 ++++- tests/schemas.js | 3 ++- tests/util.js | 2 ++ 8 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/ArrayTests.js b/tests/ArrayTests.js index 3348b2b9..15b02e8c 100644 --- a/tests/ArrayTests.js +++ b/tests/ArrayTests.js @@ -18,6 +18,7 @@ 'use strict'; +var Realm = require('realm'); var TestCase = require('./asserts'); var schemas = require('./schemas'); diff --git a/tests/ObjectTests.js b/tests/ObjectTests.js index 126ea4f2..33160c15 100644 --- a/tests/ObjectTests.js +++ b/tests/ObjectTests.js @@ -18,6 +18,7 @@ 'use strict'; +var Realm = require('realm'); var TestCase = require('./asserts'); var schemas = require('./schemas'); diff --git a/tests/RealmJSTests.mm b/tests/RealmJSTests.mm index c7f8b9cb..a12b72e7 100644 --- a/tests/RealmJSTests.mm +++ b/tests/RealmJSTests.mm @@ -111,6 +111,9 @@ static void DeleteRealmFilesAtPath(NSString *path) { [RealmJS initializeContext:context.JSGlobalContextRef]; + // Expose the global Realm object as a global 'realm' CommonJS module. + [moduleLoader addGlobalModuleObject:context[@"Realm"] forName:@"realm"]; + NSError *error; JSValue *testObjects = [moduleLoader loadModuleFromURL:scriptURL error:&error]; diff --git a/tests/RealmTests.js b/tests/RealmTests.js index d94a0852..23fc8354 100644 --- a/tests/RealmTests.js +++ b/tests/RealmTests.js @@ -18,6 +18,7 @@ 'use strict'; +var Realm = require('realm'); var TestCase = require('./asserts'); var schemas = require('./schemas'); var util = require('./util'); diff --git a/tests/ResultsTests.js b/tests/ResultsTests.js index 098692e6..140c4fa6 100644 --- a/tests/ResultsTests.js +++ b/tests/ResultsTests.js @@ -18,6 +18,7 @@ 'use strict'; +var Realm = require('realm'); var TestCase = require('./asserts'); var schemas = require('./schemas'); diff --git a/tests/package.json b/tests/package.json index 07bbe26a..36ce6dfb 100644 --- a/tests/package.json +++ b/tests/package.json @@ -1,5 +1,8 @@ { "name": "realm-tests", "version": "0.0.1", - "private": true + "private": true, + "dependencies": { + "realm": "file:../lib" + } } diff --git a/tests/schemas.js b/tests/schemas.js index 6ecd5f6d..af8280d5 100644 --- a/tests/schemas.js +++ b/tests/schemas.js @@ -18,6 +18,8 @@ 'use strict'; +var Realm = require('realm'); + var TestObjectSchema = { name: 'TestObject', properties: [ @@ -107,4 +109,3 @@ var DefaultValuesObjectSchema = { ] }; exports.DefaultValues = DefaultValuesObjectSchema; - diff --git a/tests/util.js b/tests/util.js index 0e49fa17..6b1b1bb7 100644 --- a/tests/util.js +++ b/tests/util.js @@ -18,6 +18,8 @@ 'use strict'; +var Realm = require('realm'); + exports.realmPathForFile = function(str) { var path = Realm.defaultPath; return path.substring(0, path.lastIndexOf("/") + 1) + str;