Skip to content

Commit b41faec

Browse files
author
Geoffroy Empain
committed
Add test for #63.
1 parent 359175e commit b41faec

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Editor configuration, see http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 4
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

test/functional/prototype-problem.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import "reflect-metadata";
2+
import {defaultMetadataStorage} from "../../src/storage";
3+
import {Transform} from "../../src/decorators";
4+
import {classToPlain} from "../../src/index";
5+
import moment = require("moment");
6+
import Moment = moment.Moment;
7+
8+
describe("basic functionality", () => {
9+
10+
it("should not throw error", () => {
11+
defaultMetadataStorage.clear();
12+
13+
class User {
14+
// As in https://github.com/gempain/class-transformer#additional-data-transformation
15+
@Transform(value => moment(value), {toClassOnly: true})
16+
created: Moment;
17+
}
18+
19+
const user = new User();
20+
user.created = moment();
21+
22+
const o = classToPlain(user);
23+
24+
o.should.not.be.undefined;
25+
26+
});
27+
28+
});

0 commit comments

Comments
 (0)