Fix create system class with relation/pointer

This commit is contained in:
Marco129
2016-03-03 16:37:30 +08:00
parent c6406b9e1a
commit 90a1e46905
2 changed files with 40 additions and 3 deletions

View File

@@ -422,6 +422,43 @@ describe('Schema', () => {
});
});
it('creates non-custom classes which include relation field', done => {
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('_Role', {}))
.then(mongoObj => {
expect(mongoObj).toEqual({
_id: '_Role',
createdAt: 'string',
updatedAt: 'string',
objectId: 'string',
name: 'string',
users: 'relation<_User>',
roles: 'relation<_Role>',
});
done();
});
});
it('creates non-custom classes which include pointer field', done => {
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('_Session', {}))
.then(mongoObj => {
expect(mongoObj).toEqual({
_id: '_Session',
createdAt: 'string',
updatedAt: 'string',
objectId: 'string',
restricted: 'boolean',
user: '*_User',
installationId: 'string',
sessionToken: 'string',
expiresAt: 'date',
createdWith: 'object'
});
done();
});
});
it('refuses to create two geopoints', done => {
config.database.loadSchema()
.then(schema => schema.addClassIfNotExists('NewClass', {