Files
monorepo/LCU.WebApps.Collections.RepoClient/src/containers/auction-info/auction-info-assignment/auction-info-sidebar/AuctionInfoSidebar.test.tsx
T
2026-03-17 11:09:46 -05:00

233 lines
7.3 KiB
TypeScript

import { shallow, ShallowWrapper } from "enzyme";
import moment from "moment";
import React from "react";
import { IAuctionAssignment } from "../../../../reducers/AuctionAssignmentReducer";
import { IRepoAccount } from "../../../../services/service-types/RepoAccountTypes";
import AuctionInfoSidebar from "./AuctionInfoSidebar";
describe("AuctionInfoSidebar component", () => {
let wrapper: ShallowWrapper;
let updatedRepoAccount: IRepoAccount;
let updatedAuctionAssignment: IAuctionAssignment;
beforeEach(() => {
wrapper = shallow(
<AuctionInfoSidebar
collateralImagePath={""}
conditionReportLink={""}
selectedAccount={dummyRepoAccount}
putRepoAccount={testUpdateRepoAccount}
auctionAssignment={dummyAuctionAssignment}
putAuctionAssignment={testUpdateAuctionAssignment}
holdStatuses={[]}
isAuctionLocked={false}
removedAuctionAssignment={() => {}}
/>);
});
const testUpdateRepoAccount = (repoAccount: IRepoAccount) => {
updatedRepoAccount = repoAccount;
};
const testUpdateAuctionAssignment = (auctionAssignment: IAuctionAssignment) => {
updatedAuctionAssignment = auctionAssignment;
};
const getCardView = () => {
return wrapper.find("CardView").dive();
};
it ("Redeems repo account without updating source", () => {
const redeemButton = getCardView().find(`[data-test='redeem-button']`);
redeemButton.simulate("click");
expect(updatedRepoAccount).toEqual({
...dummyRepoAccount,
status: "REDEEMED",
});
expect(updatedRepoAccount).not.toBe(dummyRepoAccount);
expect(updatedAuctionAssignment).toEqual({
...dummyAuctionAssignment,
redeemedDate: expect.any(moment)
});
expect(updatedAuctionAssignment).not.toBe(dummyAuctionAssignment);
});
it ("Disables redeem button when account has redeemed status", () => {
const redeemedAccount = {
...dummyRepoAccount,
status: "REDEEMED"
};
wrapper = shallow(
<AuctionInfoSidebar
collateralImagePath={""}
conditionReportLink={""}
selectedAccount={redeemedAccount}
putRepoAccount={testUpdateRepoAccount}
auctionAssignment={dummyAuctionAssignment}
putAuctionAssignment={testUpdateAuctionAssignment}
holdStatuses={[]}
isAuctionLocked={false}
removedAuctionAssignment={() => {}}
/>
);
const redeemButton = getCardView().find(`[data-test='redeem-button']`);
expect(redeemButton.props().disabled).toBeTruthy();
});
it ("Updates title sent date without updating source", () => {
const titleSentButton = getCardView().find(`[data-test='notify-title-sent-button']`);
titleSentButton.simulate("click");
expect(updatedAuctionAssignment).toEqual({
...dummyAuctionAssignment,
sentTitleDocsDate: expect.any(moment)
});
expect(updatedRepoAccount).not.toBe(dummyRepoAccount);
});
it ("Notify Title Sent & Redeemed Button Disabled When Auction is Locked", () => {
wrapper = wrapper.setProps({
isAuctionLocked: true
});
const titleSentButton = getCardView().find(`[data-test='notify-title-sent-button']`);
const redeemButton = getCardView().find(`[data-test='redeem-button']`);
expect(titleSentButton.props().disabled).toBe(true);
expect(redeemButton.props().disabled).toBe(true);
});
const dummyAuctionAssignment: IAuctionAssignment = {
id: 1,
repoId: 1,
isActive: true,
auctionAssignmentToCollaterals: [],
auctionId: "",
auctionCustomerNo: "",
cleaningLevel: 1,
collateralVIN: "",
floorPrice: 1,
floorPriceResponseCode: 1,
floorPriceResponseDescription: "Vehicle updated",
holdStatus: 1,
autoIMS: {
repoId: 1,
vin: "",
auctionAssignmentId: 1,
auctionCustomerNo: "",
announcedConditions: "condition 1; condition 2; condition 3;",
arbitrationReason: "",
asIs100KMiles: true,
auctionAge: 1,
auctionGuideBookPrice: 1,
buyerId: "",
buyerName: "",
chargeAmount: 1,
checkAmount: 1,
clientAge: 1,
collisionDamage: "",
daysRun: 1,
daysRunHighestBidRecordedbyAuction: "",
daystoDelivery: 1,
description: "",
isDrivable: true,
floorPriceAccepted: 1,
grossPercentFloor: 1,
highestBid: 1,
statedMileage: 1,
netPercentFloor: 1,
otherAdvanceFees: 1,
otherTotal: "",
otherAdvancedOther: "",
otherAdvancedStorage: "",
otherAdvancedTow: "",
otherMiscellaneous: "",
salePrice: 1,
titleNumber: "",
titleState: "",
titleStatus: "",
titleStatusfromAuction: "",
totalCharges: 1,
approvedVehicleGrade: 1,
isOperable: true,
status: "",
storageCost: 1,
storageRatePerDay: 1,
towCost: 1,
vehicleDecimalGradeCode: 1,
vehicleGrade: 1,
mmrNationalAdjustedPrice: 1,
mmrRegionalAdjustedPrice: 1,
mmr: "",
conditionReportLink: "",
collateralImagePath: "",
}
};
const dummyRepoAccount: IRepoAccount = {
repoId: 1,
accountNo: "",
status: "",
memberNo: 1,
loanNo: 1,
accountTypeCode: "",
branch: 1,
balance: 1,
dueToPayDate: moment(),
o4RDate: moment(),
dateFirstDelinquent: moment(),
delinquentAmount: 1,
daysDelinquent: 1,
paidSkipAmount: 1,
subStatus: "",
requiredPaymentAmount: 1,
currentDelinquentAmount: 1,
lstPmtAmt: 1,
origAmount: 1,
lastPaymentDate: moment(),
dateFirstIntellect: moment(),
primaryIndividualId: "",
bankruptcy: "",
manualRedemptionDate: moment(),
borrowers: [],
collaterals: [{
collateralId: 1,
repoId: 1,
vin: "",
make: "",
model: "",
year: 1,
repoCompanySelections: [],
retitledInLandmarkName: moment(),
auctionAssignmentId: 1,
auctionAssignmentDate: moment(),
}, {
collateralId: 1,
repoId: 1,
vin: "",
make: "",
model: "",
year: 1,
repoCompanySelections: [],
retitledInLandmarkName: moment(),
auctionAssignmentId: 2,
auctionAssignmentDate: moment(),
}, {
collateralId: 1,
repoId: 1,
vin: "",
make: "",
model: "",
year: 1,
repoCompanySelections: []
}],
repoStatusChanges: [],
};
});