Adding
This commit is contained in:
+229
@@ -0,0 +1,229 @@
|
||||
import {shallow, ShallowWrapper} from "enzyme";
|
||||
import moment, {Moment} from "moment";
|
||||
import React from "react";
|
||||
import {IRepoAccount} from "../../services/service-types/RepoAccountTypes";
|
||||
import DateCalculations from "../../shared/calculations/DateCalculations";
|
||||
import AccountDetails from "./AccountDetails";
|
||||
|
||||
describe("AccountDetails Container", () => {
|
||||
let wrapper: ShallowWrapper;
|
||||
|
||||
const dummyAccount: IRepoAccount = {
|
||||
repoId: 476,
|
||||
accountNo: "string",
|
||||
status: "string",
|
||||
memberNo: 1453,
|
||||
loanNo: 0,
|
||||
accountTypeCode: "acct-type-code",
|
||||
origAccountTypeCode: "",
|
||||
branch: 0,
|
||||
balance: 0,
|
||||
dueToPayDate: moment("1941-12-07"),
|
||||
o4RDate: moment("1945-05-07"),
|
||||
dateFirstDelinquent: moment("1918-11-11"),
|
||||
delinquentAmount: 19.45,
|
||||
daysDelinquent: 101,
|
||||
paidSkipAmount: 0,
|
||||
subStatus: "string",
|
||||
requiredPaymentAmount: 3.14,
|
||||
lstPmtAmt: 1912.00000,
|
||||
origAmount: 42,
|
||||
lastPaymentDate: moment("1865-04-15"),
|
||||
dateFirstIntellect: moment("1963-11-22"),
|
||||
primaryIndividualId: "string",
|
||||
manualRedemptionDate: moment("1812-06-12"),
|
||||
writtenOffDate: moment("1492-01-01"),
|
||||
borrowers: [],
|
||||
collaterals: [],
|
||||
repoStatusChanges: [],
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<AccountDetails
|
||||
selectedAccount={dummyAccount}
|
||||
otherRepos={"0"}
|
||||
branchMapping={[]}
|
||||
refreshCollateral={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
it("Renders Select Account Fields Correctly", () => {
|
||||
const repoDbDate = wrapper.find(`[data-test='repo-db-date']`);
|
||||
const firstDelinquent = wrapper.find(`[data-test='first-delinquent']`);
|
||||
const otherRepos = wrapper.find(`[data-test='other-repos']`);
|
||||
const daysDelqWhenAdded = wrapper.find(`[data-test='days-delq-when-added']`);
|
||||
const origAmount = wrapper.find(`[data-test='orig-amount']`);
|
||||
const balance = wrapper.find(`[data-test='balance']`);
|
||||
const lastPayment = wrapper.find(`[data-test='last-payment']`);
|
||||
const daysInStatus = wrapper.find(`[data-test='days-in-status']`);
|
||||
const daysCurrentDelq = wrapper.find(`[data-test='days-current-delq']`);
|
||||
const accountCode = wrapper.find(`[data-test='account-code']`);
|
||||
const branch = wrapper.find(`[data-test='branch']`);
|
||||
const currentDelqAmount = wrapper.find(`[data-test='current-delq-amount']`);
|
||||
const lastPmtAmount = wrapper.find(`[data-test='last-pmt-amount']`);
|
||||
const requiredAmount = wrapper.find(`[data-test='required-amount']`);
|
||||
const bankruptcy = wrapper.find(`[data-test='bankruptcy']`);
|
||||
|
||||
expect(repoDbDate.length).toBe(1);
|
||||
expect(repoDbDate.props().value).toEqual("05/07/1945");
|
||||
|
||||
expect(firstDelinquent.length).toBe(1);
|
||||
expect(firstDelinquent.props().value).toEqual("11/11/1918");
|
||||
|
||||
expect(otherRepos.length).toBe(1);
|
||||
expect(otherRepos.props().value).toEqual("0");
|
||||
|
||||
expect(daysDelqWhenAdded.length).toBe(1);
|
||||
expect(daysDelqWhenAdded.props().value).toEqual(101);
|
||||
|
||||
expect(origAmount.length).toBe(1);
|
||||
expect(origAmount.props().value).toEqual("$42.00");
|
||||
|
||||
expect(balance.length).toBe(1);
|
||||
expect(balance.props().value).toEqual("$0.00");
|
||||
|
||||
expect(lastPayment.length).toBe(1);
|
||||
expect(lastPayment.props().value).toEqual("04/15/1865");
|
||||
|
||||
expect(daysInStatus.length).toBe(1);
|
||||
expect(daysInStatus.props().value).toEqual("Missing");
|
||||
|
||||
expect(daysCurrentDelq.length).toBe(1);
|
||||
expect(daysCurrentDelq.props().value).toEqual(
|
||||
DateCalculations.DayDifference(moment("1941-12-07"), moment())
|
||||
);
|
||||
|
||||
expect(accountCode.length).toBe(1);
|
||||
expect(accountCode.props().value).toEqual("(-) / acct-type-code");
|
||||
|
||||
expect(branch.length).toBe(1);
|
||||
expect(branch.props().value).toEqual(0);
|
||||
|
||||
expect(currentDelqAmount.length).toBe(1);
|
||||
expect(currentDelqAmount.props().value).toEqual("$19.45");
|
||||
|
||||
expect(lastPmtAmount.length).toBe(1);
|
||||
expect(lastPmtAmount.props().value).toEqual("$1,912.00");
|
||||
|
||||
expect(requiredAmount.length).toBe(1);
|
||||
expect(requiredAmount.props().value).toEqual("$3.14");
|
||||
|
||||
expect(bankruptcy.length).toBe(1);
|
||||
expect(bankruptcy.props().value).toEqual("No");
|
||||
});
|
||||
|
||||
it("Written Off Date Displays No", () => {
|
||||
|
||||
const dummyAccount: IRepoAccount = {
|
||||
repoId: 476,
|
||||
accountNo: "string",
|
||||
status: "string",
|
||||
memberNo: 1453,
|
||||
loanNo: 0,
|
||||
accountTypeCode: "acct-type-code",
|
||||
origAccountTypeCode: "",
|
||||
branch: 0,
|
||||
balance: 0,
|
||||
dueToPayDate: moment("1941-12-07"),
|
||||
o4RDate: moment("1945-05-07"),
|
||||
dateFirstDelinquent: moment("1918-11-11"),
|
||||
delinquentAmount: 19.45,
|
||||
daysDelinquent: 101,
|
||||
paidSkipAmount: 0,
|
||||
subStatus: "string",
|
||||
requiredPaymentAmount: 3.14,
|
||||
lstPmtAmt: 1912.00000,
|
||||
origAmount: 42,
|
||||
lastPaymentDate: moment("1865-04-15"),
|
||||
dateFirstIntellect: moment("1963-11-22"),
|
||||
primaryIndividualId: "string",
|
||||
manualRedemptionDate: moment("1812-06-12"),
|
||||
borrowers: [],
|
||||
collaterals: [],
|
||||
repoStatusChanges: [],
|
||||
};
|
||||
|
||||
wrapper = shallow(
|
||||
<AccountDetails
|
||||
selectedAccount={dummyAccount}
|
||||
otherRepos={"0"}
|
||||
branchMapping={[]}
|
||||
refreshCollateral={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const writtenOffDate = wrapper.find(`[data-test='written-off']`);
|
||||
|
||||
expect(writtenOffDate.length).toBe(1);
|
||||
expect(writtenOffDate.props().value).toBe("No");
|
||||
});
|
||||
|
||||
it("Written Off Date Displays Date", () => {
|
||||
|
||||
wrapper = shallow(
|
||||
<AccountDetails
|
||||
selectedAccount={dummyAccount}
|
||||
otherRepos={"0"}
|
||||
branchMapping={[]}
|
||||
refreshCollateral={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const writtenOffDate = wrapper.find(`[data-test='written-off']`);
|
||||
|
||||
expect(writtenOffDate.length).toBe(1);
|
||||
expect(writtenOffDate.props().value).toBe("01/01/1492");
|
||||
});
|
||||
|
||||
it("Renders Account Code with Original Account Code Properly", () => {
|
||||
|
||||
dummyAccount.origAccountTypeCode = "orig-code";
|
||||
const tempwrapper = shallow(
|
||||
<AccountDetails
|
||||
selectedAccount={dummyAccount}
|
||||
otherRepos={"0"}
|
||||
branchMapping={[]}
|
||||
refreshCollateral={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const accountCode = tempwrapper.find(`[data-test='account-code']`);
|
||||
expect(accountCode.props().value).toBe("(orig-code) / acct-type-code");
|
||||
});
|
||||
|
||||
it("Renders the Branch Name when a mapping is available", () => {
|
||||
const tempwrapper = shallow(
|
||||
<AccountDetails
|
||||
selectedAccount={dummyAccount}
|
||||
otherRepos={"0"}
|
||||
branchMapping={[{branchId: 0, branchName: "Milwaukee"}]}
|
||||
refreshCollateral={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const branch = tempwrapper.find(`[data-test='branch']`);
|
||||
expect(branch.props().value).toBe("Milwaukee");
|
||||
});
|
||||
|
||||
it("Renders the Branch Number when branchMapping is undefined", () => {
|
||||
const tempwrapper = shallow(
|
||||
<AccountDetails
|
||||
selectedAccount={dummyAccount}
|
||||
otherRepos={"0"}
|
||||
branchMapping={[]}
|
||||
refreshCollateral={() => {
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
const branch = tempwrapper.find(`[data-test='branch']`);
|
||||
expect(branch.props().value).toBe(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user