add additional tests

This commit is contained in:
Ari Lazier 2016-05-13 15:29:59 -07:00
parent e7b341dfdb
commit d1dcd4ff3f
5 changed files with 40 additions and 9 deletions

View File

@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
02409DC21BCF11D6005F3B3E /* RealmJSCoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */; };
02414B881CE68CA200A8669F /* dates-v5.realm in Resources */ = {isa = PBXBuildFile; fileRef = 02414B871CE68CA200A8669F /* dates-v5.realm */; };
0270BC821B7D020100010E03 /* RealmJSTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0270BC7B1B7D020100010E03 /* RealmJSTests.mm */; };
027A23131CD3E379000543AE /* libRealmJS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F63FF2B11C1241E500B3B8E0 /* libRealmJS.a */; };
02D041F71CE11159000E4250 /* dates-v3.realm in Resources */ = {isa = PBXBuildFile; fileRef = 02D041F61CE11159000E4250 /* dates-v3.realm */; };
@ -83,6 +84,7 @@
/* Begin PBXFileReference section */
02409DC11BCF11D6005F3B3E /* RealmJSCoreTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RealmJSCoreTests.m; path = ios/RealmJSCoreTests.m; sourceTree = "<group>"; };
02414B871CE68CA200A8669F /* dates-v5.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dates-v5.realm"; sourceTree = "<group>"; };
025678951CAB392000FB8501 /* jsc_types.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = jsc_types.hpp; sourceTree = "<group>"; };
0270BC5A1B7CFC1300010E03 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
0270BC781B7D020100010E03 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ios/Info.plist; sourceTree = "<group>"; };
@ -328,6 +330,7 @@
isa = PBXGroup;
children = (
02D041F61CE11159000E4250 /* dates-v3.realm */,
02414B871CE68CA200A8669F /* dates-v5.realm */,
);
path = data;
sourceTree = "<group>";
@ -632,6 +635,7 @@
files = (
02D041F71CE11159000E4250 /* dates-v3.realm in Resources */,
F6BCCFE21C8380A400FE31AE /* lib in Resources */,
02414B881CE68CA200A8669F /* dates-v5.realm in Resources */,
F61378791C18EAC5008BFC51 /* js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;

View File

@ -473,15 +473,12 @@ module.exports = BaseTest.extend({
testCurrentDate: function() {
Realm.copyBundledRealmFiles();
var DateSchema = {
name: 'Date',
properties: {
currentDate: 'date'
}
};
var realm_v3 = new Realm({path: 'dates-v3.realm', schema: [schemas.DateObject]});
TestCase.assertEqual(realm_v3.objects('Date').length, 1);
TestCase.assertEqual(realm_v3.objects('Date')[0].currentDate.getTime(), 1462500087955);
var realm = new Realm({path: 'dates-v3.realm', schema: [DateSchema]});
TestCase.assertEqual(realm.objects('Date')[0].currentDate.getTime(), 1462500087955);
var realm_v5 = new Realm({path: 'dates-v5.realm', schema: [schemas.DateObject]});
TestCase.assertEqual(realm_v5.objects('Date').length, 1);
TestCase.assertEqual(realm_v5.objects('Date')[0].currentDate.getTime(), 1462500087955);
}
});

View File

@ -731,4 +731,23 @@ module.exports = BaseTest.extend({
verifyObjectSchema(schema[i]);
}
},
testCopyBundledRealmFiles: function() {
Realm.copyBundledRealmFiles();
var realm = new Realm({path: 'dates-v5.realm', schema: [schemas.DateObject]});
TestCase.assertEqual(realm.objects('Date').length, 1);
TestCase.assertEqual(realm.objects('Date')[0].currentDate.getTime(), 1462500087955);
var newDate = new Date(1);
realm.write(function() {
realm.objects('Date')[0].currentDate = newDate;
});
realm.close();
// copy should not overwrite existing files
Realm.copyBundledRealmFiles();
var realm = new Realm({path: 'dates-v5.realm', schema: [schemas.DateObject]});
TestCase.assertEqual(realm.objects('Date')[0].currentDate.getTime(), 1);
},
});

View File

@ -170,3 +170,10 @@ exports.NullQueryObject = {
{name: 'string2', type: Realm.Types.STRING},
]
};
exports.DateObject = {
name: 'Date',
properties: {
currentDate: 'date'
}
};

View File

@ -14,6 +14,7 @@
00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; };
022D592F1C0432F1001E25FE /* RealmJSTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 022D592E1C0432F1001E25FE /* RealmJSTests.mm */; };
02414B4D1CE668BF00A8669F /* dates-v3.realm in Resources */ = {isa = PBXBuildFile; fileRef = 02414B4B1CE668BF00A8669F /* dates-v3.realm */; };
02414B8A1CE68CA900A8669F /* dates-v5.realm in Resources */ = {isa = PBXBuildFile; fileRef = 02414B891CE68CA900A8669F /* dates-v5.realm */; };
02DE87671C0CE46100A42BFC /* RealmReactTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 02DE87661C0CE46100A42BFC /* RealmReactTests.m */; };
133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; };
139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; };
@ -138,6 +139,7 @@
00E356EE1AD99517003FC87E /* RealmReactTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RealmReactTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
022D592E1C0432F1001E25FE /* RealmJSTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RealmJSTests.mm; path = ../../ios/RealmJSTests.mm; sourceTree = "<group>"; };
02414B4B1CE668BF00A8669F /* dates-v3.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dates-v3.realm"; sourceTree = "<group>"; };
02414B891CE68CA900A8669F /* dates-v5.realm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "dates-v5.realm"; sourceTree = "<group>"; };
02DE87661C0CE46100A42BFC /* RealmReactTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = RealmReactTests.m; path = ReactTests/RealmReactTests.m; sourceTree = "<group>"; };
02DE87711C0CE55100A42BFC /* RealmJSTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RealmJSTests.h; path = ../../ios/RealmJSTests.h; sourceTree = "<group>"; };
139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = "../node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj"; sourceTree = "<group>"; };
@ -232,6 +234,7 @@
isa = PBXGroup;
children = (
02414B4B1CE668BF00A8669F /* dates-v3.realm */,
02414B891CE68CA900A8669F /* dates-v5.realm */,
);
name = data;
path = ../../data;
@ -555,6 +558,7 @@
files = (
02414B4D1CE668BF00A8669F /* dates-v3.realm in Resources */,
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
02414B8A1CE68CA900A8669F /* dates-v5.realm in Resources */,
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;