@onehat/data 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -301,9 +301,35 @@ describe('Entity', function() {
301
301
  expect(_.isEqual(reverseMapped2, expected2)).to.be.true;
302
302
  });
303
303
 
304
- it('getReverseMappedRawValues', function() {
305
- const result = this.entity.getReverseMappedRawValues();
306
- expect(_.isEqual(result, this.data)).to.be.true;
304
+ it('getReverseMappedRawValues (check deep matches)', function() {
305
+ const schema = new Schema({
306
+ name: 'baz',
307
+ model: {
308
+ idProperty: 'foo',
309
+ displayProperty: 'bar',
310
+ properties: [
311
+ { name: 'foo', type: 'int' },
312
+ { name: 'bar' },
313
+ { name: 'baz', mapping: 'baz.test.val', type: 'bool', defaultValue: null, },
314
+ { name: 'baz2', mapping: 'baz.test2', type: 'bool', defaultValue: null, },
315
+ ],
316
+ },
317
+ }),
318
+ data = {
319
+ foo: 1,
320
+ bar: 'one',
321
+ baz: {
322
+ test: {
323
+ val: true,
324
+ },
325
+ test2: false,
326
+ },
327
+ },
328
+ entity = new Entity(schema, data);
329
+ entity.initialize();
330
+
331
+ const result = entity.getReverseMappedRawValues();
332
+ expect(_.isEqual(result, data)).to.be.true;
307
333
  });
308
334
 
309
335
  it('build a new entity from an existing one using getDataForNewEntity', function() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/data",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "JS data modeling package with adapters for many storage mediums.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/src/Entity.js CHANGED
@@ -640,7 +640,7 @@ class Entity extends EventEmitter {
640
640
  let propertyValues = {};
641
641
  _.forOwn(this.properties, (property) => {
642
642
  const reverseMapped = Entity.getReverseMappedRawValue(property);
643
- _.assign(propertyValues, reverseMapped);
643
+ _.merge(propertyValues, reverseMapped);
644
644
  });
645
645
  return propertyValues;
646
646
  }
@@ -411,7 +411,7 @@ export default class Property extends EventEmitter {
411
411
  */
412
412
  getMapping = () => {
413
413
  if (this.isDestroyed) {
414
- throw Error('this.getMappedName is no longer valid. Property has been destroyed.');
414
+ throw Error('this.getMapping is no longer valid. Property has been destroyed.');
415
415
  }
416
416
  return this.mapping;
417
417
  }