Skip to content

Commit

Permalink
psp-7082 ensure that primary contact logic for org teams works when t…
Browse files Browse the repository at this point in the history
…here is no org primary contact available.
  • Loading branch information
devinleighsmith committed Nov 2, 2023
1 parent 16400dc commit b86a3ed
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { AcquisitionTeamFormModel } from './models';

describe('acquisition model tests', () => {
it('omits the primary contact if unset', () => {
let model = new AcquisitionTeamFormModel('testType');
model.primaryContactId = '';
expect(model.toApi(1)?.primaryContactId).toBeUndefined();
});

it('omits the primary contact if null', () => {
let model = new AcquisitionTeamFormModel('testType');
model.primaryContactId = null as any;
expect(model.toApi(1)?.primaryContactId).toBeUndefined();
});

it('omits the primary contact if undefined', () => {
let model = new AcquisitionTeamFormModel('testType');
model.primaryContactId = undefined as any;
expect(model.toApi(1)?.primaryContactId).toBeUndefined();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AcquisitionTeamFormModel {
person: undefined,
organizationId: organizationId ?? undefined,
organization: undefined,
primaryContactId: this.primaryContactId !== '' ? Number(this.primaryContactId) : undefined,
primaryContactId: !isNaN(+this.primaryContactId) ? Number(this.primaryContactId) : undefined,
teamProfileType: toTypeCode(this.contactTypeCode),
teamProfileTypeCode: this.contactTypeCode,
};
Expand Down

0 comments on commit b86a3ed

Please sign in to comment.