Comparing version 0.2.5 to 0.2.6
@@ -53,3 +53,6 @@ class Masker { | ||
const touched = layer[prop]._settleObject(destination[prop], source[prop], props, schema); | ||
const holder = destination[prop] || {}; | ||
const touched = layer[prop]._settleObject(holder, source[prop], props, schema); | ||
destination[prop] = new layer[prop].Clazz(holder); | ||
if (touched) { | ||
@@ -56,0 +59,0 @@ settled.touched = touched; |
{ | ||
"name": "carnaval", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -257,2 +257,50 @@ const test = require('ava'); | ||
test('assign empty deeply, touched & schema', t => { | ||
const mask = Mask.cover(Box).with({ | ||
thing: { | ||
physical: true | ||
} | ||
}); | ||
const physical = true; | ||
const box = new Box(); | ||
const touched = mask.settle( | ||
box, | ||
new Box({thing: new Thing({physical})}) | ||
); | ||
t.true(box.thing instanceof Thing); | ||
t.is(box.thing.name, undefined); | ||
t.is(box.thing.description, undefined); | ||
t.is(box.thing.size, undefined); | ||
t.is(box.thing.physical, physical); | ||
t.is(touched.thing, undefined); | ||
}); | ||
test('assign empty tuned deeply, touched & schema', t => { | ||
const mask = Mask.cover(Box).with({ | ||
thing: Mask.cover(Thing).with({ | ||
physical: true | ||
}) | ||
}); | ||
const physical = true; | ||
const box = new Box(); | ||
const touched = mask.settle( | ||
box, | ||
new Box({thing: new Thing({physical})}) | ||
); | ||
t.true(box.thing instanceof Thing); | ||
t.is(box.thing.name, undefined); | ||
t.is(box.thing.description, undefined); | ||
t.is(box.thing.size, undefined); | ||
t.is(box.thing.physical, physical); | ||
t.is(touched.thing, undefined); | ||
}); | ||
class Shipping extends Domain { | ||
@@ -367,3 +415,3 @@ get props() { | ||
const boxes = new Boxes({things: []}); | ||
mask.settle( | ||
const touched = mask.settle( | ||
boxes, | ||
@@ -378,2 +426,5 @@ new Boxes(({things: [new Thing({name: 'overriden', description, physical})]})) | ||
t.is(boxes.things[0].physical, physical); | ||
t.true(touched.things[0].name); | ||
t.true(touched.things[0].description); | ||
}); | ||
@@ -380,0 +431,0 @@ |
116547
2874