Adding
This commit is contained in:
+150
@@ -0,0 +1,150 @@
|
||||
import { mount } from "enzyme";
|
||||
import React from "react";
|
||||
import MonthlyProductTotal from "./MonthlyProductTotal";
|
||||
import { Product2 } from "../../../shared/enumerations/Product";
|
||||
import { IEmployee } from "../../../shared/models/Employee";
|
||||
import moment from "moment";
|
||||
import { UserType } from "../../../shared/models/Auditable";
|
||||
|
||||
describe("A component for monthly product totals", () => {
|
||||
const mockUser: IEmployee = {
|
||||
role: {
|
||||
name: "baseRole",
|
||||
rank: 1,
|
||||
permissions: [],
|
||||
description: "fake role",
|
||||
hasCommissions: true
|
||||
},
|
||||
departments: [
|
||||
{
|
||||
departmentId: 55,
|
||||
employeeId: "11771",
|
||||
isHome: true,
|
||||
note: "fake home assignment",
|
||||
startDate: moment(),
|
||||
endDate: moment(),
|
||||
created: moment(),
|
||||
createdBy: "nobody",
|
||||
createdByType: UserType.System,
|
||||
lastUpdated: moment(),
|
||||
id: 5,
|
||||
lastUpdatedBy: "nobody",
|
||||
lastUpdatedByType: UserType.System
|
||||
}
|
||||
],
|
||||
baseRole: "none",
|
||||
homeDepartment: "none",
|
||||
personId: 555,
|
||||
adEmail: "[email protected]",
|
||||
employeeId: "11771",
|
||||
fullName: "Test McTester",
|
||||
additionalPermissions: []
|
||||
};
|
||||
|
||||
it("Displays a valid total when everything is -zero-", () => {
|
||||
const data = {
|
||||
personnelGoals: {
|
||||
departmentId: 5,
|
||||
year: 2020,
|
||||
month: 1,
|
||||
personnel: [mockUser], // IEmployee[];
|
||||
goals: {
|
||||
"11771": {
|
||||
productGoals: {
|
||||
NewChecking: 0,
|
||||
CreditCard: 0,
|
||||
LIC: 0,
|
||||
Mortgage: 0,
|
||||
Vehicle: 0
|
||||
}
|
||||
}
|
||||
} // PerPersonGoalType;
|
||||
}, // IPersonnelGoals;
|
||||
pendingChanges: [], // IGoalChangeRequest[];
|
||||
product: Product2.Vehicle,
|
||||
departmentTotal: 0
|
||||
};
|
||||
const wrapper = mount(
|
||||
<MonthlyProductTotal
|
||||
product={data.product}
|
||||
departmentTotal={data.departmentTotal}
|
||||
personnelGoals={data.personnelGoals}
|
||||
pendingChanges={data.pendingChanges}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.html()).toBe('<span class="text-normal">0 (0%)</span>');
|
||||
});
|
||||
|
||||
it("Displays a valid total when everything is 100%", () => {
|
||||
const data = {
|
||||
personnelGoals: {
|
||||
departmentId: 5,
|
||||
year: 2020,
|
||||
month: 1,
|
||||
personnel: [mockUser], // IEmployee[];
|
||||
goals: {
|
||||
"11771": {
|
||||
productGoals: {
|
||||
NewChecking: 5,
|
||||
CreditCard: 5,
|
||||
LIC: 0,
|
||||
Mortgage: 0,
|
||||
Vehicle: 25
|
||||
}
|
||||
}
|
||||
} // PerPersonGoalType;
|
||||
}, // IPersonnelGoals;
|
||||
pendingChanges: [], // IGoalChangeRequest[];
|
||||
product: Product2.Vehicle,
|
||||
departmentTotal: 25
|
||||
};
|
||||
const wrapper = mount(
|
||||
<MonthlyProductTotal
|
||||
product={data.product}
|
||||
departmentTotal={data.departmentTotal}
|
||||
personnelGoals={data.personnelGoals}
|
||||
pendingChanges={data.pendingChanges}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.html()).toBe(
|
||||
'<span class="text-normal">25 (100%)</span>'
|
||||
);
|
||||
});
|
||||
|
||||
it("Displays a valid total when everything is 50%", () => {
|
||||
const data = {
|
||||
personnelGoals: {
|
||||
departmentId: 5,
|
||||
year: 2020,
|
||||
month: 1,
|
||||
personnel: [mockUser], // IEmployee[];
|
||||
goals: {
|
||||
"11771": {
|
||||
productGoals: {
|
||||
NewChecking: 3,
|
||||
CreditCard: 510,
|
||||
GAPInsurance: 610,
|
||||
LIC: 9,
|
||||
Mortgage: 4,
|
||||
Vehicle: 10
|
||||
}
|
||||
}
|
||||
} // PerPersonGoalType;
|
||||
}, // IPersonnelGoals;
|
||||
pendingChanges: [], // IGoalChangeRequest[];
|
||||
product: Product2.Vehicle,
|
||||
departmentTotal: 20
|
||||
};
|
||||
const wrapper = mount(
|
||||
<MonthlyProductTotal
|
||||
product={data.product}
|
||||
departmentTotal={data.departmentTotal}
|
||||
personnelGoals={data.personnelGoals}
|
||||
pendingChanges={data.pendingChanges}
|
||||
/>
|
||||
);
|
||||
expect(wrapper.html()).toBe(
|
||||
'<span class="text-normal">10 (50%)</span>'
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user