Skip to content
/ mapper Public
  • Rate limit · GitHub

    Access has been restricted

    You have triggered a rate limit.

    Please wait a few minutes before you try again;
    in some cases this may take up to an hour.

  • Notifications You must be signed in to change notification settings
  • Fork 91

Commit

Permalink
test: add self map case
Browse files Browse the repository at this point in the history
Rate limit · GitHub

Access has been restricted

You have triggered a rate limit.

Please wait a few minutes before you try again;
in some cases this may take up to an hour.

nartc committed Jul 8, 2021
1 parent 6740a5d commit 03c7091
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@ import { mapFrom } from '@automapper/core';
import type { MapAction, Mapper, MappingProfile } from '@automapper/types';
import { SimpleUser, SimpleUserVm } from '../models/simple-user';

export const selfUserProfile: MappingProfile = (mapper) => {
mapper.createMap(SimpleUser, SimpleUser);
};

export const simpleUserProfileFactory =
(actions?: { beforeMap: MapAction; afterMap: MapAction }): MappingProfile =>
(mapper: Mapper) => {
23 changes: 23 additions & 0 deletions packages/integration-test/src/lib/with-classes/self-map.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { setupClasses } from '../setup.spec';
import { SimpleUser } from './fixtures/models/simple-user';
import { selfUserProfile } from './fixtures/profiles/simple-user.profile';

describe('Map - Self Map', () => {
const [mapper] = setupClasses('selfMap');

it('should map', () => {
mapper.addProfile(selfUserProfile);

const vm = mapper.map(
{
firstName: 'Chau',
lastName: 'Tran',
},
SimpleUser,
SimpleUser
);
expect(vm).toBeTruthy();
expect(vm.firstName).toEqual('Chau');
expect(vm.lastName).toEqual('Tran');
});
});

0 comments on commit 03c7091

Please sign in to comment.