-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from SyslogicNL/develop
0.1.2
- Loading branch information
Showing
6 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import {expect} from 'chai'; | ||
import {array, custom, date, deserialize, object, serializable, serialize} from "../src/graph-serializer"; | ||
|
||
/** @todo find a strategy to handle any of the standard objects, such as defined in | ||
* https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Global_Objects | ||
* and | ||
* https://developer.mozilla.org/en-US/docs/Web/API | ||
*/ | ||
|
||
describe('Extra tests', () => { | ||
|
||
describe('null value in nested class', () => { | ||
|
||
class Foo { | ||
@serializable() name:string; | ||
} | ||
class Bar { | ||
@serializable() name:string; | ||
@serializable() nest:Foo; | ||
} | ||
|
||
it('deserialize', () => { | ||
|
||
let output = deserialize(Bar,{ | ||
name: "bar", | ||
nest: { | ||
name: "foo" | ||
} | ||
}); | ||
expect(output).to.be.instanceOf(Bar); | ||
expect(output.nest.name).to.equal('foo'); | ||
|
||
output = deserialize(Bar,{ | ||
name: "bar", | ||
nest: null | ||
}); | ||
expect(output.nest).to.equal(null); | ||
|
||
}); | ||
}); | ||
|
||
describe('null object value class', () => { | ||
// Test for use case. If decorated object property is null, it should be deserialized as such | ||
class Foo { | ||
@serializable() fooName: string; | ||
} | ||
class Bar { | ||
@serializable({scheme: object(Foo)}) foo: Foo; | ||
} | ||
it('deserialize', () => { | ||
let output = deserialize(Bar,{ | ||
name: 'bar', | ||
foo: null, | ||
}) | ||
expect(output.foo).to.equal(null); | ||
}); | ||
}); | ||
|
||
describe('null object value in decorator-less class', () => { | ||
|
||
class Foo { | ||
foo: string; | ||
} | ||
class Bar { | ||
@serializable({scheme: object(Foo)}) foo: Foo; | ||
} | ||
it('deserialize', () => { | ||
let output = deserialize(Bar,{ | ||
name: 'bar', | ||
foo: null, | ||
}); | ||
expect(output.foo).to.equal(null); | ||
}); | ||
}); | ||
|
||
|
||
}); | ||
|