-
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): extend uses customProperties instead of properties because…
… it is custom
- Loading branch information
Chau Tran
authored and
Chau Tran
committed
Oct 25, 2022
1 parent
65c6a74
commit b29f2ef
Showing
4 changed files
with
57 additions
and
8 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
47 changes: 47 additions & 0 deletions
47
packages/integration-test/src/classes/issues/503/503.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,47 @@ | ||
import { AutoMap, classes } from '@automapper/classes'; | ||
import { | ||
CamelCaseNamingConvention, | ||
createMap, | ||
createMapper, | ||
extend, | ||
forMember, | ||
nullSubstitution, | ||
} from '@automapper/core'; | ||
|
||
export class Source { | ||
@AutoMap(() => String) | ||
foo!: string | null; | ||
} | ||
|
||
export class Destination { | ||
@AutoMap() | ||
foo?: string; | ||
} | ||
|
||
export class Destination2 extends Destination {} | ||
|
||
describe('Issue 503', () => { | ||
const mapper = createMapper({ | ||
strategyInitializer: classes(), | ||
namingConventions: new CamelCaseNamingConvention(), | ||
}); | ||
|
||
it('should map properly', () => { | ||
const mapping = createMap( | ||
mapper, | ||
Source, | ||
Destination, | ||
forMember((d) => d.foo, nullSubstitution(undefined)) | ||
); | ||
createMap(mapper, Source, Destination2, extend(mapping)); | ||
|
||
const source = new Source(); | ||
source.foo = null; | ||
|
||
const destination = mapper.map(source, Source, Destination); | ||
expect(destination.foo).toEqual(undefined); | ||
|
||
const destination2 = mapper.map(source, Source, Destination2); | ||
expect(destination2.foo).toEqual(undefined); | ||
}); | ||
}); |