Skip to content

Commit 9ec8fe2

Browse files
author
Vlad Balin
committed
added unit test for bugs
1 parent 8b6f50f commit 9ec8fe2

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed

tests/typescript/dist/index.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16126,6 +16126,43 @@ describe('Bugs from Volicon Observer', function () {
1612616126
chai_1(p._validationError).not.to.be.undefined;
1612716127
});
1612816128
});
16129+
describe('assignFrom', function () {
16130+
it('copy the value if the target is null', function () {
16131+
var Inner = (function (_super) {
16132+
__extends(Inner, _super);
16133+
function Inner() {
16134+
return _super !== null && _super.apply(this, arguments) || this;
16135+
}
16136+
__decorate([
16137+
attr,
16138+
__metadata("design:type", String)
16139+
], Inner.prototype, "name", void 0);
16140+
Inner = __decorate([
16141+
define
16142+
], Inner);
16143+
return Inner;
16144+
}(Record));
16145+
var Test = (function (_super) {
16146+
__extends(Test, _super);
16147+
function Test() {
16148+
return _super !== null && _super.apply(this, arguments) || this;
16149+
}
16150+
__decorate([
16151+
attr(Inner.value(null)),
16152+
__metadata("design:type", Inner)
16153+
], Test.prototype, "inner", void 0);
16154+
Test = __decorate([
16155+
define
16156+
], Test);
16157+
return Test;
16158+
}(Record));
16159+
var target = new Test(), source = new Test({ inner: { name: "ron" } });
16160+
chai_1(target.inner).to.be.null;
16161+
target.assignFrom(source);
16162+
chai_1(target.inner !== source.inner).to.be.true;
16163+
console.log(target.inner.cid, source.inner.cid);
16164+
});
16165+
});
1612916166
});
1613016167

1613116168
})));

tests/typescript/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/typescript/lib/reported-bugs.js

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/typescript/lib/reported-bugs.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/typescript/src/reported-bugs.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,26 @@ describe( 'Bugs from Volicon Observer', () =>{
159159
expect( p._validationError ).not.to.be.undefined;
160160
} );
161161
});
162+
163+
describe( 'assignFrom', ()=>{
164+
it( 'copy the value if the target is null', () =>{
165+
@define class Inner extends Record {
166+
@attr name : string
167+
}
168+
169+
@define class Test extends Record {
170+
@attr( Inner.value( null ) ) inner : Inner;
171+
}
172+
173+
const target = new Test(),
174+
source = new Test({ inner : { name : "ron" } } );
175+
176+
expect( target.inner ).to.be.null;
177+
178+
target.assignFrom( source );
179+
180+
expect( target.inner !== source.inner ).to.be.true;
181+
console.log( target.inner.cid, source.inner.cid );
182+
});
183+
});
162184
} );

0 commit comments

Comments
 (0)