Skip to content

Commit

Permalink
test(nestjs-integration-test): add sample profile test
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Jan 5, 2021
1 parent 85b7ee9 commit 7d9aa00
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { classes } from '@automapper/classes';
import { createMapper } from '@automapper/core';
import { getMapperToken } from '@automapper/nestjs';
import type { Mapper } from '@automapper/types';
import { Test } from '@nestjs/testing';
import { Address, AddressVm } from '../models/address';
import { AddressProfile } from './address.profile';

describe('addressProfile', () => {
let mapper: Mapper;
beforeEach(async () => {
const moduleRef = await Test.createTestingModule({
providers: [
{
provide: getMapperToken(),
useValue: createMapper({ name: '', pluginInitializer: classes }),
},
AddressProfile,
],
}).compile();
mapper = moduleRef.get<Mapper>(getMapperToken());
});

it('', () => {
const address = new Address();
address.street = 'street';
address.city = 'city';
address.state = 'state';

const vm = mapper.map(address, AddressVm, Address);
expect(vm.formattedAddress).toEqual(
`${address.street} ${address.city} ${address.state}`
);
});
});

0 comments on commit 7d9aa00

Please sign in to comment.