-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add custom properties to isolate forMember configuration
ISSUE CLOSED: #497
- Loading branch information
Showing
5 changed files
with
78 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
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
51 changes: 51 additions & 0 deletions
51
packages/integration-test/src/classes/issues/497/497.spec.ts
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,51 @@ | ||
import { AutoMap, classes } from '@automapper/classes'; | ||
import { | ||
CamelCaseNamingConvention, | ||
createMap, | ||
createMapper, | ||
} from '@automapper/core'; | ||
|
||
export class UserEntity { | ||
@AutoMap() | ||
id!: number; | ||
|
||
@AutoMap() | ||
name!: string; | ||
|
||
@AutoMap() | ||
sharedInfo!: string; | ||
|
||
password!: string; | ||
} | ||
|
||
export class UserResponse { | ||
@AutoMap() | ||
id!: number; | ||
|
||
@AutoMap() | ||
name!: string; | ||
|
||
@AutoMap() | ||
sharedInfo!: string; | ||
} | ||
|
||
describe('Issue 497', () => { | ||
const mapper = createMapper({ | ||
strategyInitializer: classes(), | ||
namingConventions: new CamelCaseNamingConvention(), | ||
}); | ||
|
||
it('should map properly', () => { | ||
createMap(mapper, UserEntity, UserResponse); | ||
|
||
const user = new UserEntity(); | ||
user.id = 123; | ||
user.name = 'Chau'; | ||
user.sharedInfo = 'info'; | ||
|
||
const responses = mapper.mapArray([user], UserEntity, UserResponse); | ||
expect(responses).toEqual([ | ||
{ id: 123, name: 'Chau', sharedInfo: 'info' }, | ||
]); | ||
}); | ||
}); |