Add test that checks schema validation

This commit is contained in:
Scott Kyle 2016-01-04 16:10:48 -08:00
parent 2a7c336ba9
commit c34990759d
1 changed files with 22 additions and 0 deletions

View File

@ -66,6 +66,28 @@ module.exports = BaseTest.extend({
TestCase.assertEqual(realm.objects('TestObject')[0].doubleCol, 1) TestCase.assertEqual(realm.objects('TestObject')[0].doubleCol, 1)
}, },
testRealmConstructorSchemaValidation: function() {
TestCase.assertThrows(function() {
new Realm({schema: schemas.AllTypes});
}, 'The schema should be an array');
TestCase.assertThrows(function() {
new Realm({schema: ['SomeType']});
}, 'The schema should be an array of objects');
TestCase.assertThrows(function() {
new Realm({schema: [{}]});
}, 'The schema should be an array of ObjectSchema objects');
TestCase.assertThrows(function() {
new Realm({schema: [{name: 'SomeObject'}]});
}, 'The schema should be an array of ObjectSchema objects');
TestCase.assertThrows(function() {
new Realm({schema: [{properties: {intCol: Realm.Types.INT}}]});
}, 'The schema should be an array of ObjectSchema objects');
},
testDefaultPath: function() { testDefaultPath: function() {
var defaultRealm = new Realm({schema: []}); var defaultRealm = new Realm({schema: []});
TestCase.assertEqual(defaultRealm.path, Realm.defaultPath); TestCase.assertEqual(defaultRealm.path, Realm.defaultPath);