Fix: repair_helper_tests (!35)
Bug fix in tests related to intermittent test failures. when using repair kits it is possible the amount of repair selected will be less than the max which is "randomly" calculated. Closes SPT-AKI/Issues#7 Co-authored-by: Dev <dev@noreply.dev.sp-tarkov.com> Co-authored-by: snekcode <code.snakes@gmail.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/35 Co-authored-by: snekcode <snekcode@noreply.dev.sp-tarkov.com> Co-committed-by: snekcode <snekcode@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
505735cfad
commit
c141d108be
@ -6,7 +6,6 @@ import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
|||||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
|
||||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||||
import { TestHelper } from "./common/TestHelper";
|
import { TestHelper } from "./common/TestHelper";
|
||||||
@ -16,7 +15,6 @@ let logger: ILogger;
|
|||||||
let jsonUtil: JsonUtil;
|
let jsonUtil: JsonUtil;
|
||||||
let randomUtil: RandomUtil;
|
let randomUtil: RandomUtil;
|
||||||
let configServer: ConfigServer;
|
let configServer: ConfigServer;
|
||||||
let localisationService: LocalisationService;
|
|
||||||
let databaseServer: DatabaseServer;
|
let databaseServer: DatabaseServer;
|
||||||
let helper: RepairHelper;
|
let helper: RepairHelper;
|
||||||
|
|
||||||
@ -28,7 +26,6 @@ describe("BotHelper", () => {
|
|||||||
jsonUtil = testHelper.getTestJsonUtil();
|
jsonUtil = testHelper.getTestJsonUtil();
|
||||||
randomUtil = testHelper.getTestRandomUtil();
|
randomUtil = testHelper.getTestRandomUtil();
|
||||||
configServer = testHelper.getTestConfigServer();
|
configServer = testHelper.getTestConfigServer();
|
||||||
localisationService = testHelper.getTestLocalisationService();
|
|
||||||
databaseServer = testHelper.getTestDatabaseServer();
|
databaseServer = testHelper.getTestDatabaseServer();
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -46,7 +43,7 @@ describe("BotHelper", () => {
|
|||||||
expect(helper).toBeInstanceOf(RepairHelper);
|
expect(helper).toBeInstanceOf(RepairHelper);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updateItemDurability() repairkit with slick armor with max dura degredation", () =>
|
it("updateItemDurability() repairkit with slick armor with max dura degradation", () =>
|
||||||
{
|
{
|
||||||
const slickTpl = "5e4abb5086f77406975c9342";
|
const slickTpl = "5e4abb5086f77406975c9342";
|
||||||
const itemToRepair: Item = {
|
const itemToRepair: Item = {
|
||||||
@ -69,7 +66,7 @@ describe("BotHelper", () => {
|
|||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(80);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(80);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updateItemDurability() trader with slick armor with max dura degredation - partial repair", () =>
|
it("updateItemDurability() trader with slick armor with max dura degradation - partial repair", () =>
|
||||||
{
|
{
|
||||||
const slickTpl = "5e4abb5086f77406975c9342";
|
const slickTpl = "5e4abb5086f77406975c9342";
|
||||||
const itemToRepair: Item = {
|
const itemToRepair: Item = {
|
||||||
@ -90,10 +87,10 @@ describe("BotHelper", () => {
|
|||||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 5, useRepairKit, 1.2, useDegridation);
|
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 5, useRepairKit, 1.2, useDegridation);
|
||||||
|
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(80);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(80);
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeGreaterThan(60);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(itemToRepair.upd?.Repairable?.MaxDurability);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updateItemDurability() trader with slick armor, no dura degredation", () =>
|
it("updateItemDurability() trader with slick armor, no dura degradation", () =>
|
||||||
{
|
{
|
||||||
const slickTpl = "5e4abb5086f77406975c9342";
|
const slickTpl = "5e4abb5086f77406975c9342";
|
||||||
const itemToRepair: Item = {
|
const itemToRepair: Item = {
|
||||||
@ -109,15 +106,15 @@ describe("BotHelper", () => {
|
|||||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[slickTpl];
|
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[slickTpl];
|
||||||
const isArmor = true;
|
const isArmor = true;
|
||||||
const useRepairKit = false;
|
const useRepairKit = false;
|
||||||
const useDegridation = false;
|
const useDegradation = false;
|
||||||
|
|
||||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 20, useRepairKit, 1.2, useDegridation);
|
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 20, useRepairKit, 1.2, useDegradation);
|
||||||
|
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBe(80);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBe(80);
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBe(itemToRepair.upd?.Repairable?.MaxDurability);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(itemToRepair.upd?.Repairable?.MaxDurability);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updateItemDurability() repairkit with g36 with max dura degredation - Full repair", () =>
|
it("updateItemDurability() repairkit with g36 with max dura degradation - Full repair", () =>
|
||||||
{
|
{
|
||||||
const itemCurrentDura = 68;
|
const itemCurrentDura = 68;
|
||||||
const itemCurrentMaxDura = 100;
|
const itemCurrentMaxDura = 100;
|
||||||
@ -136,15 +133,15 @@ describe("BotHelper", () => {
|
|||||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[g36Tpl];
|
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[g36Tpl];
|
||||||
const isArmor = false;
|
const isArmor = false;
|
||||||
const useRepairKit = true;
|
const useRepairKit = true;
|
||||||
const useDegridation = true;
|
const useDegradation = true;
|
||||||
|
|
||||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, duraDifference, useRepairKit, 1, useDegridation);
|
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, duraDifference, useRepairKit, 1, useDegradation);
|
||||||
|
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(100);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(100);
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBe(itemToRepair.upd?.Repairable?.MaxDurability);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(itemToRepair.upd?.Repairable?.MaxDurability);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updateItemDurability() trader with g36 with max dura degredation - Full repair", () =>
|
it("updateItemDurability() trader with g36 with max dura degradation - Full repair", () =>
|
||||||
{
|
{
|
||||||
const itemCurrentDura = 68;
|
const itemCurrentDura = 68;
|
||||||
const itemCurrentMaxDura = 100;
|
const itemCurrentMaxDura = 100;
|
||||||
@ -163,15 +160,15 @@ describe("BotHelper", () => {
|
|||||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[g36Tpl];
|
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[g36Tpl];
|
||||||
const isArmor = false;
|
const isArmor = false;
|
||||||
const useRepairKit = false;
|
const useRepairKit = false;
|
||||||
const useDegridation = true;
|
const useDegradation = true;
|
||||||
|
|
||||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, duraDifference, useRepairKit, 1.2, useDegridation);
|
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, duraDifference, useRepairKit, 1.2, useDegradation);
|
||||||
|
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(100);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(100);
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBe(itemToRepair.upd?.Repairable?.MaxDurability);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(itemToRepair.upd?.Repairable?.MaxDurability);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updateItemDurability() faceshield broken use repairkit with max dura degredation", () =>
|
it("updateItemDurability() faceshield broken use repairkit with max dura degradation", () =>
|
||||||
{
|
{
|
||||||
const twExfilBallisticFaceShieldTpl = "5e00cdd986f7747473332240";
|
const twExfilBallisticFaceShieldTpl = "5e00cdd986f7747473332240";
|
||||||
const itemToRepair: Item = {
|
const itemToRepair: Item = {
|
||||||
@ -191,13 +188,13 @@ describe("BotHelper", () => {
|
|||||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[twExfilBallisticFaceShieldTpl];
|
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[twExfilBallisticFaceShieldTpl];
|
||||||
const isArmor = true;
|
const isArmor = true;
|
||||||
const useRepairKit = true;
|
const useRepairKit = true;
|
||||||
const useDegridation = true;
|
const useDegradation = true;
|
||||||
|
|
||||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 5, useRepairKit, 1, useDegridation);
|
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 5, useRepairKit, 1, useDegradation);
|
||||||
|
|
||||||
expect(itemToRepair.upd?.FaceShield?.Hits).toBe(0);
|
expect(itemToRepair.upd?.FaceShield?.Hits).toBe(0);
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(45);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(45);
|
||||||
expect(itemToRepair.upd?.Repairable?.Durability).toBe(itemToRepair.upd?.Repairable?.MaxDurability);
|
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(itemToRepair.upd?.Repairable?.MaxDurability);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("isWeaponTemplate() g36 weapon", () =>
|
it("isWeaponTemplate() g36 weapon", () =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user