Skip to content

Commit

Permalink
Do not attempt to return the person name if tenant is not a person. (#…
Browse files Browse the repository at this point in the history
…645)

* Do not attempt to return the person name if tenant is not a person.

* test corrections - deposit code using current date with snapshots, this will always fail.

Co-authored-by: Smith <[email protected]>
  • Loading branch information
devinleighsmith and Smith authored Dec 16, 2021
1 parent b5305b3 commit 50f36a4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/api/Areas/Leases/Mapping/Search/LeaseMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.LFileNo, src => src.LFileNo)
.Map(dest => dest.Properties, src => src.GetProperties())
.Map(dest => dest.ProgramName, src => src.GetProgramName())
.Map(dest => dest.TenantNames, src => src.PimsLeaseTenants.Select(t => t.Person.GetFullName()));
.Map(dest => dest.TenantNames, src => src.PimsLeaseTenants.Where(t => t != null && t.Person != null).Select(t => t.Person.GetFullName()));
}
}
}
4 changes: 4 additions & 0 deletions backend/entities/Helpers/PersonExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ public static string GetMobilePhoneNumber(this PimsPerson person)
/// <returns></returns>
public static string GetFullName(this PimsPerson person)
{
if(person == null)
{
return null;
}
string[] names = { person.FirstName, person.MiddleNames, person.Surname };
return String.Join(" ", names.Where(n => n != null && n.Trim() != String.Empty));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ const setup = (renderOptions: RenderOptions & { lease?: IFormLease } = {}): Rend
};

describe('Lease Deposits', () => {
beforeEach(() => {
Date.now = jest.fn().mockReturnValue(new Date('2020-10-15T18:33:37.000Z'));
});
afterAll(() => {
jest.restoreAllMocks();
});
it('renders as expected', () => {
const result = setup({
lease: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,15 @@ exports[`Lease Deposits renders as expected 1`] = `
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$1.75
-$8.75
</div>
<div
class="td"
role="cell"
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$501.75
$491.25
</div>
</div>
</div>
Expand Down Expand Up @@ -299,15 +299,15 @@ Integer nec odio.
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$115.5
$66.5
</div>
<div
class="td"
role="cell"
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$2,115.5
$2,066.5
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ const setup = (renderOptions: RenderOptions & IDepositsReceivedTableProps = {})
};

describe('DepositsReceivedTable component', () => {
beforeEach(() => {
Date.now = jest.fn().mockReturnValue(new Date('2020-11-30T18:33:37.000Z'));
});
afterAll(() => {
jest.restoreAllMocks();
});
it('renders as expected', () => {
const { asFragment } = setup({ dataSource: [...mockDeposits] });
expect(asFragment()).toMatchSnapshot();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ exports[`DepositsReceivedTable component renders as expected 1`] = `
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$1.75
-$7.88
</div>
<div
class="td"
role="cell"
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$501.75
$492.13
</div>
</div>
</div>
Expand Down Expand Up @@ -260,15 +260,15 @@ Integer nec odio.
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$115.5
$70
</div>
<div
class="td"
role="cell"
style="box-sizing: border-box; flex: 40 0 auto; min-width: 30px; width: 40px; justify-content: flex-end; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
title=""
>
$2,115.5
$2,070
</div>
</div>
</div>
Expand Down

0 comments on commit 50f36a4

Please sign in to comment.