8000 More tests. · hubcarl/json-typescript-mapper@959f4af · GitHub
[go: up one dir, main page]

Skip to content

Commit 959f4af

Browse files
Mönnich Daniel, ENT-BD-PDDMönnich Daniel, ENT-BD-PDD
Mönnich Daniel, ENT-BD-PDD
authored and
Mönnich Daniel, ENT-BD-PDD
committed
More tests.
1 parent d363ed3 commit 959f4af

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

spec/custom-converter.js

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

spec/custom-converter.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ class Student {
2323
constructor() {}
2424
}
2525

26+
27+
//TODO put in main test file where serialization is tested
2628
describe('custom-converter', function () {
2729

2830
it('should use the custom converter if available for deserialization', function () {
@@ -35,8 +37,6 @@ describe('custom-converter', function () {
3537
expect(student.dateOfBirth).to.be.instanceof(Date);
3638
});
3739

38-
//TODO serialize test
39-
4040
});
4141

4242

@@ -106,9 +106,19 @@ describe('serialize', function () {
106106
expect(serializedInstance.lastName).to.be.undefined;
107107
});
108108

109-
//TODO test exclude
110-
111-
//TODO test deep serialization
109+
it('should work recursively if clazz is specified in meta data', function () {
110+
class OtherClass {
111+
@JsonProperty({name: 'date', customConverter: dateConverter})
112+
date: Date = new Date();
113+
}
114+
class ClassWithClassProp {
115+
@JsonProperty({ name: 'other', clazz: OtherClass})
116+
other: OtherClass = new OtherClass();
117+
}
118+
const instance = new ClassWithClassProp();
119+
const serializedInstance = serialize(instance);
120+
expect(serializedInstance.other.date).to.equal('some-date');
121+
});
112122

113123
//TODO test with Arrays
114124

0 commit comments

Comments
 (0)
0