Skip to content

Commit 94fcaf2

Browse files
committed
Add test for custom transformation with @expose
1 parent af605ae commit 94fcaf2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/functional/custom-transform.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,24 @@ import * as moment from "moment";
66

77
describe("custom transformation decorator", () => {
88

9+
it("@Expose decorator with 'name' option should work with @Transform decorator", () => {
10+
defaultMetadataStorage.clear();
11+
12+
class User {
13+
14+
@Expose({name: 'user_name'})
15+
@Transform(value => value.toUpperCase())
16+
name: string;
17+
}
18+
19+
let plainUser = {
20+
user_name: "Johny Cage"
21+
};
22+
23+
const classedUser = plainToClass(User, plainUser);
24+
classedUser.name.should.be.equal("JOHNY CAGE");
25+
});
26+
927
it("@Transform decorator logic should be executed depend of toPlainOnly and toClassOnly set", () => {
1028
defaultMetadataStorage.clear();
1129

0 commit comments

Comments
 (0)