This commit is contained in:
committed by
Florent Vilmart
parent
4ea455b20a
commit
1eff210a51
@@ -149,7 +149,7 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('handles array, object, date', (done) => {
|
||||
it('handles creating an array, object, date', (done) => {
|
||||
let adapter = new MongoStorageAdapter({ uri: databaseURI });
|
||||
let obj = {
|
||||
array: [1, 2, 3],
|
||||
@@ -189,4 +189,52 @@ describe_only_db('mongo')('MongoStorageAdapter', () => {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("handles updating a single object with array, object date", (done) => {
|
||||
let adapter = new MongoStorageAdapter({ uri: databaseURI });
|
||||
|
||||
let schema = { fields: {
|
||||
array: { type: 'Array' },
|
||||
object: { type: 'Object' },
|
||||
date: { type: 'Date' },
|
||||
} };
|
||||
|
||||
|
||||
adapter.createObject('MyClass', schema, {})
|
||||
.then(() => adapter._rawFind('MyClass', {}))
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
let update = {
|
||||
array: [1, 2, 3],
|
||||
object: {foo: 'bar'},
|
||||
date: {
|
||||
__type: 'Date',
|
||||
iso: '2016-05-26T20:55:01.154Z',
|
||||
},
|
||||
};
|
||||
let query = {};
|
||||
return adapter.findOneAndUpdate('MyClass', schema, query, update)
|
||||
})
|
||||
.then(results => {
|
||||
let mob = results;
|
||||
expect(mob.array instanceof Array).toBe(true);
|
||||
expect(typeof mob.object).toBe('object');
|
||||
expect(mob.date.__type).toBe('Date');
|
||||
expect(mob.date.iso).toBe('2016-05-26T20:55:01.154Z');
|
||||
return adapter._rawFind('MyClass', {});
|
||||
})
|
||||
.then(results => {
|
||||
expect(results.length).toEqual(1);
|
||||
let mob = results[0];
|
||||
expect(mob.array instanceof Array).toBe(true);
|
||||
expect(typeof mob.object).toBe('object');
|
||||
expect(mob.date instanceof Date).toBe(true);
|
||||
done();
|
||||
})
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
fail();
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user