Removes Old Jest Tests (!169)
These should not be used. Branch `3.8.0` has newer Vitest tests configured. Co-authored-by: Refringe <brownelltyler@gmail.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/169
This commit is contained in:
parent
4ac12ef70a
commit
083a2a798e
16
project/.vscode/launch.json
vendored
16
project/.vscode/launch.json
vendored
@ -20,22 +20,6 @@
|
||||
],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"outputCapture": "std"
|
||||
},
|
||||
{
|
||||
"name": "Run Jest UnitTests",
|
||||
"type": "node",
|
||||
"runtimeVersion": "18.15.0",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/node_modules/.bin/jest",
|
||||
"args": [
|
||||
"--runInBand"
|
||||
],
|
||||
"console": "integratedTerminal",
|
||||
"internalConsoleOptions": "neverOpen",
|
||||
"disableOptimisticBPs": true,
|
||||
"windows": {
|
||||
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
import { pathsToModuleNameMapper } from "ts-jest";
|
||||
import type { JestConfigWithTsJest } from "ts-jest";
|
||||
import { compilerOptions } from "./tsconfig.json";
|
||||
|
||||
const config: JestConfigWithTsJest = {
|
||||
preset: "ts-jest",
|
||||
testEnvironment: "node",
|
||||
roots: ["./tests/"],
|
||||
modulePaths: [compilerOptions.baseUrl],
|
||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
|
||||
};
|
||||
|
||||
export default config;
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aki-server",
|
||||
"version": "3.7.1",
|
||||
"version": "3.7.3",
|
||||
"author": "SPT-AKI Server",
|
||||
"license": "NCSA",
|
||||
"main": "obj/bundle.js",
|
||||
@ -16,10 +16,6 @@
|
||||
"lint:fix": "biome check --apply-unsafe --max-diagnostics=200 . && dprint fmt --incremental=false",
|
||||
"style": "dprint check --incremental=false",
|
||||
"style:fix": "dprint fmt --incremental=false",
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"test:ui": "vitest --ui --coverage",
|
||||
"build:release": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:release",
|
||||
"build:debug": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:debug",
|
||||
"build:bleeding": "cross-env PKG_CACHE_PATH=\"./.pkg-cache\" gulp build:bleeding",
|
||||
@ -47,13 +43,10 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.3.3",
|
||||
"@jest/globals": "29.7.0",
|
||||
"@pnpm/exe": "8.9.0",
|
||||
"@swc/cli": "0.1.62",
|
||||
"@swc/core": "1.3.92",
|
||||
"@swc/jest": "0.2.29",
|
||||
"@types/i18n": "0.13.7",
|
||||
"@types/jest": "29.5.5",
|
||||
"@types/node": "18.18.4",
|
||||
"@types/proper-lockfile": "4.1.2",
|
||||
"@types/semver": "7.5.3",
|
||||
@ -66,12 +59,10 @@
|
||||
"gulp": "4.0.2",
|
||||
"gulp-execa": "5.0.1",
|
||||
"gulp-rename": "2.0.0",
|
||||
"jest": "29.7.0",
|
||||
"madge": "6.1.0",
|
||||
"pkg": "5.8.1",
|
||||
"pkg-fetch": "3.5.2",
|
||||
"resedit": "2.0.0",
|
||||
"ts-jest": "29.1.1",
|
||||
"ts-node-dev": "2.0.0",
|
||||
"tsconfig-paths": "4.2.0",
|
||||
"typedoc": "0.25.2",
|
||||
|
@ -1,92 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
import { BotDifficultyHelper } from "@spt-aki/helpers/BotDifficultyHelper";
|
||||
import { BotHelper } from "@spt-aki/helpers/BotHelper";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||
import { MockHelper } from "./common/MockHelper";
|
||||
import { TestHelper } from "./common/TestHelper";
|
||||
|
||||
const mockHelper = new MockHelper();
|
||||
let testHelper: TestHelper;
|
||||
let logger: ILogger;
|
||||
let jsonUtil: JsonUtil;
|
||||
let randomUtil: RandomUtil;
|
||||
let configServer: ConfigServer;
|
||||
let localisationService: LocalisationService;
|
||||
let databaseServer: DatabaseServer;
|
||||
let botHelper: BotHelper;
|
||||
|
||||
describe("BotHelper", () =>
|
||||
{
|
||||
beforeAll(async () =>
|
||||
{
|
||||
testHelper = await TestHelper.fetchTestHelper();
|
||||
logger = testHelper.getTestLogger();
|
||||
jsonUtil = testHelper.getTestJsonUtil();
|
||||
randomUtil = testHelper.getTestRandomUtil();
|
||||
configServer = testHelper.getTestConfigServer();
|
||||
localisationService = testHelper.getTestLocalisationService();
|
||||
databaseServer = testHelper.getTestDatabaseServer();
|
||||
botHelper = testHelper.getTestBotHelper();
|
||||
});
|
||||
|
||||
let botDifficultyHelper: BotDifficultyHelper;
|
||||
beforeEach(() =>
|
||||
{
|
||||
botDifficultyHelper = new BotDifficultyHelper(
|
||||
logger,
|
||||
jsonUtil,
|
||||
databaseServer,
|
||||
randomUtil,
|
||||
localisationService,
|
||||
botHelper,
|
||||
configServer,
|
||||
);
|
||||
});
|
||||
|
||||
it("BotDifficultyHelper type check", () =>
|
||||
{
|
||||
expect(botDifficultyHelper).toBeInstanceOf(BotDifficultyHelper);
|
||||
});
|
||||
|
||||
it("chooseRandomDifficulty()", () =>
|
||||
{
|
||||
expect(["easy", "normal", "hard", "impossible"]).toContain(botDifficultyHelper.chooseRandomDifficulty());
|
||||
});
|
||||
|
||||
it("getPmcDifficultySettings() easy", () =>
|
||||
{
|
||||
expect(botDifficultyHelper.getPmcDifficultySettings("bear", "easy", "sptUsec", "sptBear")).not.toBeFalsy();
|
||||
});
|
||||
|
||||
it("getPmcDifficultySettings() random", () =>
|
||||
{
|
||||
expect(botDifficultyHelper.getPmcDifficultySettings("usec", "random", "sptUsec", "sptBear")).not.toBeFalsy();
|
||||
});
|
||||
|
||||
it("getPmcDifficultySettings() difficulty set to 'medium' in config", () =>
|
||||
{
|
||||
const configServerMock = mockHelper.getMockConfigServer();
|
||||
const mockBotConfig = { kind: "aki-bot", pmc: { difficulty: "medium", enemyTypes: ["assault"] } };
|
||||
configServerMock.setup((x) => x.getConfig(ConfigTypes.BOT)).returns(() => mockBotConfig);
|
||||
|
||||
const testOnlyHelper = new BotDifficultyHelper(
|
||||
logger,
|
||||
jsonUtil,
|
||||
databaseServer,
|
||||
randomUtil,
|
||||
localisationService,
|
||||
botHelper,
|
||||
configServerMock.object,
|
||||
);
|
||||
|
||||
expect(testOnlyHelper.getPmcDifficultySettings("usec", "medium", "sptUsec", "sptBear")).not.toBeFalsy();
|
||||
});
|
||||
});
|
@ -1,66 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
import { BotHelper } from "@spt-aki/helpers/BotHelper";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||
import { TestHelper } from "./common/TestHelper";
|
||||
|
||||
let testHelper: TestHelper;
|
||||
let logger: ILogger;
|
||||
let jsonUtil: JsonUtil;
|
||||
let randomUtil: RandomUtil;
|
||||
let configServer: ConfigServer;
|
||||
let localisationService: LocalisationService;
|
||||
let databaseServer: DatabaseServer;
|
||||
|
||||
describe("BotHelper", () =>
|
||||
{
|
||||
beforeAll(async () =>
|
||||
{
|
||||
testHelper = await TestHelper.fetchTestHelper();
|
||||
logger = testHelper.getTestLogger();
|
||||
jsonUtil = testHelper.getTestJsonUtil();
|
||||
randomUtil = testHelper.getTestRandomUtil();
|
||||
configServer = testHelper.getTestConfigServer();
|
||||
localisationService = testHelper.getTestLocalisationService();
|
||||
databaseServer = testHelper.getTestDatabaseServer();
|
||||
});
|
||||
|
||||
let helper: BotHelper;
|
||||
beforeEach(() =>
|
||||
{
|
||||
helper = new BotHelper(logger, jsonUtil, databaseServer, randomUtil, localisationService, configServer);
|
||||
});
|
||||
|
||||
it("BotHelper type check", () =>
|
||||
{
|
||||
expect(helper).toBeInstanceOf(BotHelper);
|
||||
});
|
||||
|
||||
it("isBotPmc()", () =>
|
||||
{
|
||||
expect(helper.isBotPmc("usec")).toBe(true);
|
||||
expect(helper.isBotPmc("bear")).toBe(true);
|
||||
expect(helper.isBotPmc("faketype")).toBe(false);
|
||||
});
|
||||
|
||||
it("isBotFollower()", () =>
|
||||
{
|
||||
expect(helper.isBotFollower("followerBully")).toBe(true);
|
||||
expect(helper.isBotFollower("FoLlOwErBULlY")).toBe(true);
|
||||
expect(helper.isBotFollower("followerSanitar")).toBe(true);
|
||||
expect(helper.isBotFollower("botFollower")).toBe(false);
|
||||
});
|
||||
|
||||
it("getBotTemplate()", () =>
|
||||
{
|
||||
expect(helper.getBotTemplate("assault")).not.toBeFalsy();
|
||||
expect(helper.getBotTemplate("fakebottype")).toBeFalsy();
|
||||
expect(helper.getBotTemplate("")).toBeFalsy();
|
||||
});
|
||||
});
|
@ -1,54 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
import { PaymentHelper } from "@spt-aki/helpers/PaymentHelper";
|
||||
|
||||
describe("test text", () =>
|
||||
{
|
||||
let helper: PaymentHelper;
|
||||
beforeEach(() =>
|
||||
{
|
||||
helper = new PaymentHelper();
|
||||
});
|
||||
|
||||
it("PaymentHelper type check", () =>
|
||||
{
|
||||
expect(helper).toBeInstanceOf(PaymentHelper);
|
||||
});
|
||||
|
||||
it("isMoneyTpl() USD", () =>
|
||||
{
|
||||
expect(helper.isMoneyTpl("5696686a4bdc2da3298b456a")).toBe(true);
|
||||
});
|
||||
|
||||
it("isMoneyTpl() euro", () =>
|
||||
{
|
||||
expect(helper.isMoneyTpl("569668774bdc2da2298b4568")).toBe(true); // euro
|
||||
});
|
||||
|
||||
it("isMoneyTpl() rouble", () =>
|
||||
{
|
||||
expect(helper.isMoneyTpl("5696686a4bdc2da3298b456a")).toBe(true); // rub
|
||||
expect(helper.isMoneyTpl("")).toBe(false);
|
||||
expect(helper.isMoneyTpl("faketpl")).toBe(false);
|
||||
});
|
||||
|
||||
it("isMoneyTpl() empty tpl", () =>
|
||||
{
|
||||
expect(helper.isMoneyTpl("")).toBe(false);
|
||||
});
|
||||
|
||||
it("isMoneyTpl() invalid tpl", () =>
|
||||
{
|
||||
expect(helper.isMoneyTpl("faketpl")).toBe(false);
|
||||
});
|
||||
|
||||
it("getCurrency()", () =>
|
||||
{
|
||||
expect(helper.getCurrency("EUR")).toBe("569668774bdc2da2298b4568");
|
||||
expect(helper.getCurrency("USD")).toBe("5696686a4bdc2da3298b456a");
|
||||
expect(helper.getCurrency("RUB")).toBe("5449016a4bdc2d6f028b456f");
|
||||
expect(helper.getCurrency("1234353434534")).toBe("");
|
||||
expect(helper.getCurrency("")).toBe("");
|
||||
});
|
||||
});
|
@ -1,204 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { RepairHelper } from "@spt-aki/helpers/RepairHelper";
|
||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||
import { TestHelper } from "./common/TestHelper";
|
||||
|
||||
let testHelper: TestHelper;
|
||||
let logger: ILogger;
|
||||
let jsonUtil: JsonUtil;
|
||||
let randomUtil: RandomUtil;
|
||||
let configServer: ConfigServer;
|
||||
let databaseServer: DatabaseServer;
|
||||
let helper: RepairHelper;
|
||||
|
||||
describe("BotHelper", () =>
|
||||
{
|
||||
beforeAll(async () =>
|
||||
{
|
||||
testHelper = await TestHelper.fetchTestHelper();
|
||||
logger = testHelper.getTestLogger();
|
||||
jsonUtil = testHelper.getTestJsonUtil();
|
||||
randomUtil = testHelper.getTestRandomUtil();
|
||||
configServer = testHelper.getTestConfigServer();
|
||||
databaseServer = testHelper.getTestDatabaseServer();
|
||||
});
|
||||
|
||||
beforeEach(() =>
|
||||
{
|
||||
helper = new RepairHelper(logger, jsonUtil, randomUtil, databaseServer, configServer);
|
||||
});
|
||||
|
||||
it("RepairHelper type check", () =>
|
||||
{
|
||||
expect(helper).toBeInstanceOf(RepairHelper);
|
||||
});
|
||||
|
||||
it("updateItemDurability() repairkit with slick armor with max dura degradation", () =>
|
||||
{
|
||||
const slickTpl = "5e4abb5086f77406975c9342";
|
||||
const itemToRepair: Item = {
|
||||
_id: "12345",
|
||||
_tpl: slickTpl,
|
||||
upd: { Repairable: { Durability: 60, MaxDurability: 80 } },
|
||||
};
|
||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[slickTpl];
|
||||
const isArmor = true;
|
||||
const useRepairKit = true;
|
||||
const useDegridation = true;
|
||||
|
||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 5, useRepairKit, 1, useDegridation);
|
||||
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(80);
|
||||
});
|
||||
|
||||
it("updateItemDurability() trader with slick armor with max dura degradation - partial repair", () =>
|
||||
{
|
||||
const slickTpl = "5e4abb5086f77406975c9342";
|
||||
const itemToRepair: Item = {
|
||||
_id: "12345",
|
||||
_tpl: slickTpl,
|
||||
upd: { Repairable: { Durability: 60, MaxDurability: 80 } },
|
||||
};
|
||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[slickTpl];
|
||||
const isArmor = true;
|
||||
const useRepairKit = false;
|
||||
const useDegridation = true;
|
||||
|
||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 5, useRepairKit, 1.2, useDegridation);
|
||||
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(80);
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(
|
||||
itemToRepair.upd?.Repairable?.MaxDurability,
|
||||
);
|
||||
});
|
||||
|
||||
it("updateItemDurability() trader with slick armor, no dura degradation", () =>
|
||||
{
|
||||
const slickTpl = "5e4abb5086f77406975c9342";
|
||||
const itemToRepair: Item = {
|
||||
_id: "12345",
|
||||
_tpl: slickTpl,
|
||||
upd: { Repairable: { Durability: 60, MaxDurability: 80 } },
|
||||
};
|
||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[slickTpl];
|
||||
const isArmor = true;
|
||||
const useRepairKit = false;
|
||||
const useDegradation = false;
|
||||
|
||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 20, useRepairKit, 1.2, useDegradation);
|
||||
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBe(80);
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(
|
||||
itemToRepair.upd?.Repairable?.MaxDurability,
|
||||
);
|
||||
});
|
||||
|
||||
it("updateItemDurability() repairkit with g36 with max dura degradation - Full repair", () =>
|
||||
{
|
||||
const itemCurrentDura = 68;
|
||||
const itemCurrentMaxDura = 100;
|
||||
const duraDifference = itemCurrentMaxDura - itemCurrentDura;
|
||||
const g36Tpl = "623063e994fc3f7b302a9696";
|
||||
const itemToRepair: Item = {
|
||||
_id: "12345",
|
||||
_tpl: g36Tpl,
|
||||
upd: { Repairable: { Durability: itemCurrentDura, MaxDurability: itemCurrentMaxDura } },
|
||||
};
|
||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[g36Tpl];
|
||||
const isArmor = false;
|
||||
const useRepairKit = true;
|
||||
const useDegradation = true;
|
||||
|
||||
helper.updateItemDurability(
|
||||
itemToRepair,
|
||||
itemToRepairDetails,
|
||||
isArmor,
|
||||
duraDifference,
|
||||
useRepairKit,
|
||||
1,
|
||||
useDegradation,
|
||||
);
|
||||
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(100);
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(
|
||||
itemToRepair.upd?.Repairable?.MaxDurability,
|
||||
);
|
||||
});
|
||||
|
||||
it("updateItemDurability() trader with g36 with max dura degradation - Full repair", () =>
|
||||
{
|
||||
const itemCurrentDura = 68;
|
||||
const itemCurrentMaxDura = 100;
|
||||
const duraDifference = itemCurrentMaxDura - itemCurrentDura;
|
||||
const g36Tpl = "623063e994fc3f7b302a9696";
|
||||
const itemToRepair: Item = {
|
||||
_id: "12345",
|
||||
_tpl: g36Tpl,
|
||||
upd: { Repairable: { Durability: itemCurrentDura, MaxDurability: itemCurrentMaxDura } },
|
||||
};
|
||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates?.items[g36Tpl];
|
||||
const isArmor = false;
|
||||
const useRepairKit = false;
|
||||
const useDegradation = true;
|
||||
|
||||
helper.updateItemDurability(
|
||||
itemToRepair,
|
||||
itemToRepairDetails,
|
||||
isArmor,
|
||||
duraDifference,
|
||||
useRepairKit,
|
||||
1.2,
|
||||
useDegradation,
|
||||
);
|
||||
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(100);
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(
|
||||
itemToRepair.upd?.Repairable?.MaxDurability,
|
||||
);
|
||||
});
|
||||
|
||||
it("updateItemDurability() faceshield broken use repairkit with max dura degradation", () =>
|
||||
{
|
||||
const twExfilBallisticFaceShieldTpl = "5e00cdd986f7747473332240";
|
||||
const itemToRepair: Item = {
|
||||
_id: "12345",
|
||||
_tpl: twExfilBallisticFaceShieldTpl,
|
||||
upd: { Repairable: { Durability: 30, MaxDurability: 45 }, FaceShield: { Hits: 2 } },
|
||||
};
|
||||
|
||||
const itemToRepairDetails = <ITemplateItem>databaseServer.getTables().templates
|
||||
?.items[twExfilBallisticFaceShieldTpl];
|
||||
const isArmor = true;
|
||||
const useRepairKit = true;
|
||||
const useDegradation = true;
|
||||
|
||||
helper.updateItemDurability(itemToRepair, itemToRepairDetails, isArmor, 5, useRepairKit, 1, useDegradation);
|
||||
|
||||
expect(itemToRepair.upd?.FaceShield?.Hits).toBe(0);
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThan(45);
|
||||
expect(itemToRepair.upd?.Repairable?.Durability).toBeLessThanOrEqual(
|
||||
itemToRepair.upd?.Repairable?.MaxDurability,
|
||||
);
|
||||
});
|
||||
|
||||
it("isWeaponTemplate() g36 weapon", () =>
|
||||
{
|
||||
const result = helper.isWeaponTemplate("623063e994fc3f7b302a9696");
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("isWeaponTemplate() slick armor", () =>
|
||||
{
|
||||
const result = helper.isWeaponTemplate("5e4abb5086f77406975c9342");
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
@ -1,56 +0,0 @@
|
||||
import { QuestHelper } from "@spt-aki/helpers/QuestHelper";
|
||||
import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
|
||||
import * as TypeMoq from "typemoq";
|
||||
|
||||
import { ImageRouter } from "@spt-aki/routers/ImageRouter";
|
||||
import { ItemEventRouter } from "@spt-aki/routers/ItemEventRouter";
|
||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { PaymentService } from "@spt-aki/services/PaymentService";
|
||||
import { VFS } from "@spt-aki/utils/VFS";
|
||||
|
||||
export class MockHelper
|
||||
{
|
||||
public getMockImageRouter(): TypeMoq.IMock<ImageRouter>
|
||||
{
|
||||
return TypeMoq.Mock.ofType(ImageRouter);
|
||||
}
|
||||
|
||||
public getMockVFS(): TypeMoq.IMock<VFS>
|
||||
{
|
||||
// vfsMock.setup(x => x.getFiles(TypeMoq.It.isAnyString())).returns(() => []);
|
||||
return TypeMoq.Mock.ofType(VFS);
|
||||
}
|
||||
|
||||
public getMockConfigServer(): TypeMoq.IMock<ConfigServer>
|
||||
{
|
||||
return TypeMoq.Mock.ofType(TestConfigServer);
|
||||
}
|
||||
|
||||
public getItemEventRouter(): TypeMoq.IMock<ItemEventRouter>
|
||||
{
|
||||
return TypeMoq.Mock.ofType(ItemEventRouter);
|
||||
}
|
||||
|
||||
public getQuestHelper(): TypeMoq.IMock<QuestHelper>
|
||||
{
|
||||
return TypeMoq.Mock.ofType(QuestHelper);
|
||||
}
|
||||
|
||||
public getTraderHelper(): TypeMoq.IMock<TraderHelper>
|
||||
{
|
||||
return TypeMoq.Mock.ofType(TraderHelper);
|
||||
}
|
||||
|
||||
public getPaymentServiceMock(): TypeMoq.IMock<PaymentService>
|
||||
{
|
||||
return TypeMoq.Mock.ofType(PaymentService);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestConfigServer extends ConfigServer
|
||||
{
|
||||
public override initialize(): void
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
@ -1,177 +0,0 @@
|
||||
import { BotHelper } from "@spt-aki/helpers/BotHelper";
|
||||
import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper";
|
||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { ItemBaseClassService } from "@spt-aki/services/ItemBaseClassService";
|
||||
import { LocaleService } from "@spt-aki/services/LocaleService";
|
||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { AsyncQueue } from "@spt-aki/utils/AsyncQueue";
|
||||
import { DatabaseImporter } from "@spt-aki/utils/DatabaseImporter";
|
||||
import { EncodingUtil } from "@spt-aki/utils/EncodingUtil";
|
||||
import { HashUtil } from "@spt-aki/utils/HashUtil";
|
||||
import { ImporterUtil } from "@spt-aki/utils/ImporterUtil";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { MathUtil } from "@spt-aki/utils/MathUtil";
|
||||
import { ObjectId } from "@spt-aki/utils/ObjectId";
|
||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||
import { UUidGenerator } from "@spt-aki/utils/UUidGenerator";
|
||||
import { VFS } from "@spt-aki/utils/VFS";
|
||||
import { MockHelper } from "./MockHelper";
|
||||
import WinstonLogger from "./__mocks__/WinstonLogger";
|
||||
|
||||
export class TestHelper
|
||||
{
|
||||
logger: ILogger;
|
||||
asyncQueue: AsyncQueue;
|
||||
uuidGenerator: UUidGenerator;
|
||||
timeUtil: TimeUtil;
|
||||
vfs: VFS;
|
||||
hashUtil: HashUtil;
|
||||
jsonUtil: JsonUtil;
|
||||
randomUtil: RandomUtil;
|
||||
encodingUtil: EncodingUtil;
|
||||
importerUtil: ImporterUtil;
|
||||
configServer: ConfigServer;
|
||||
objectId: ObjectId;
|
||||
mathUtil: MathUtil;
|
||||
databaseServer: DatabaseServer;
|
||||
itemHelper: ItemHelper;
|
||||
localeService: LocaleService;
|
||||
localisationService: LocalisationService;
|
||||
handbookHelper: HandbookHelper;
|
||||
itemBaseClassService: ItemBaseClassService;
|
||||
botHelper: BotHelper;
|
||||
|
||||
public static async fetchTestHelper()
|
||||
{
|
||||
const initTestHelper = new TestHelper();
|
||||
const mockHelper = new MockHelper();
|
||||
|
||||
const dbImporter = new DatabaseImporter(
|
||||
initTestHelper.logger,
|
||||
initTestHelper.vfs,
|
||||
initTestHelper.jsonUtil,
|
||||
initTestHelper.localisationService,
|
||||
initTestHelper.databaseServer,
|
||||
mockHelper.getMockImageRouter().object,
|
||||
initTestHelper.encodingUtil,
|
||||
initTestHelper.hashUtil,
|
||||
initTestHelper.importerUtil,
|
||||
);
|
||||
await dbImporter.onLoad();
|
||||
return initTestHelper;
|
||||
}
|
||||
|
||||
constructor()
|
||||
{
|
||||
this.logger = new WinstonLogger();
|
||||
this.asyncQueue = new AsyncQueue();
|
||||
this.uuidGenerator = new UUidGenerator();
|
||||
this.timeUtil = new TimeUtil();
|
||||
this.vfs = new VFS(this.asyncQueue, this.uuidGenerator);
|
||||
this.hashUtil = new HashUtil(this.timeUtil);
|
||||
this.jsonUtil = new JsonUtil(this.vfs, this.hashUtil, this.logger);
|
||||
this.randomUtil = new RandomUtil(this.jsonUtil, this.logger);
|
||||
this.configServer = new ConfigServer(this.logger, this.vfs, this.jsonUtil);
|
||||
this.objectId = new ObjectId(this.timeUtil);
|
||||
this.mathUtil = new MathUtil();
|
||||
|
||||
this.databaseServer = new DatabaseServer();
|
||||
this.localeService = new LocaleService(this.logger, this.databaseServer, this.configServer);
|
||||
this.localisationService = new LocalisationService(this.logger, this.localeService);
|
||||
|
||||
this.encodingUtil = new EncodingUtil();
|
||||
this.importerUtil = new ImporterUtil(this.vfs, this.jsonUtil);
|
||||
|
||||
this.handbookHelper = new HandbookHelper(this.databaseServer);
|
||||
this.itemBaseClassService = new ItemBaseClassService(
|
||||
this.logger,
|
||||
this.localisationService,
|
||||
this.databaseServer,
|
||||
);
|
||||
this.itemHelper = new ItemHelper(
|
||||
this.logger,
|
||||
this.hashUtil,
|
||||
this.jsonUtil,
|
||||
this.randomUtil,
|
||||
this.objectId,
|
||||
this.mathUtil,
|
||||
this.databaseServer,
|
||||
this.handbookHelper,
|
||||
this.itemBaseClassService,
|
||||
this.localisationService,
|
||||
this.localeService,
|
||||
);
|
||||
this.botHelper = new BotHelper(
|
||||
this.logger,
|
||||
this.jsonUtil,
|
||||
this.databaseServer,
|
||||
this.randomUtil,
|
||||
this.localisationService,
|
||||
this.configServer,
|
||||
);
|
||||
}
|
||||
|
||||
public getTestLogger(): ILogger
|
||||
{
|
||||
return this.logger;
|
||||
}
|
||||
|
||||
public getTestUuidGenerator(): UUidGenerator
|
||||
{
|
||||
return this.uuidGenerator;
|
||||
}
|
||||
|
||||
public getTestVFS(): VFS
|
||||
{
|
||||
return this.vfs;
|
||||
}
|
||||
|
||||
public getTestHashUtil(): HashUtil
|
||||
{
|
||||
return new HashUtil(this.timeUtil);
|
||||
}
|
||||
|
||||
public getTestJsonUtil(): JsonUtil
|
||||
{
|
||||
return this.jsonUtil;
|
||||
}
|
||||
|
||||
public getTestRandomUtil(): RandomUtil
|
||||
{
|
||||
return this.randomUtil;
|
||||
}
|
||||
|
||||
public getTestConfigServer(): ConfigServer
|
||||
{
|
||||
return this.configServer;
|
||||
}
|
||||
|
||||
public getTestItemHelper(): ItemHelper
|
||||
{
|
||||
return this.itemHelper;
|
||||
}
|
||||
|
||||
public getTestDatabaseServer(): DatabaseServer
|
||||
{
|
||||
return this.databaseServer;
|
||||
}
|
||||
|
||||
public getTestLocalisationService(): LocalisationService
|
||||
{
|
||||
return this.localisationService;
|
||||
}
|
||||
|
||||
public getTestBotHelper(): BotHelper
|
||||
{
|
||||
return this.botHelper;
|
||||
}
|
||||
|
||||
public getTestMathUtil(): MathUtil
|
||||
{
|
||||
return this.mathUtil;
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
import { Daum } from "@spt-aki/models/eft/itemEvent/IItemEventRouterRequest";
|
||||
import { LogBackgroundColor } from "@spt-aki/models/spt/logging/LogBackgroundColor";
|
||||
import { LogTextColor } from "@spt-aki/models/spt/logging/LogTextColor";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
|
||||
export default class WinstonLogger implements ILogger
|
||||
{
|
||||
writeToLogFile(data: string | Daum): void
|
||||
{
|
||||
console.log(`writeToLogFile ${data}`);
|
||||
}
|
||||
logWithColor(
|
||||
data: string | Record<string, unknown>,
|
||||
textColor: LogTextColor,
|
||||
backgroundColor?: LogBackgroundColor | undefined,
|
||||
): void
|
||||
{
|
||||
console.log(`logWithColor ${data}`);
|
||||
}
|
||||
error(data: string): void
|
||||
{
|
||||
console.log(`error ${data}`);
|
||||
}
|
||||
warning(data: string): void
|
||||
{
|
||||
console.log(`warning ${data}`);
|
||||
}
|
||||
success(data: string): void
|
||||
{
|
||||
console.log(`success ${data}`);
|
||||
}
|
||||
info(data: string): void
|
||||
{
|
||||
console.log(`info ${data}`);
|
||||
}
|
||||
debug(data: string | Record<string, unknown>, onlyShowInConsole?: boolean | undefined): void
|
||||
{
|
||||
console.log(`debug ${data}`);
|
||||
}
|
||||
|
||||
log(msg: string): void
|
||||
{
|
||||
console.log(msg);
|
||||
}
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
import { HashUtil } from "@spt-aki/utils/HashUtil";
|
||||
import { TestHelper } from "../common/TestHelper";
|
||||
|
||||
const testHelper = new TestHelper();
|
||||
|
||||
describe("test text", () =>
|
||||
{
|
||||
let hashUtil: HashUtil;
|
||||
beforeEach(() =>
|
||||
{
|
||||
hashUtil = testHelper.getTestHashUtil();
|
||||
});
|
||||
|
||||
it("HashUtil type check", () =>
|
||||
{
|
||||
expect(hashUtil).toBeInstanceOf(HashUtil);
|
||||
});
|
||||
|
||||
it("generate()", () =>
|
||||
{
|
||||
expect(hashUtil.generate()).toHaveLength(24);
|
||||
});
|
||||
|
||||
it("generateMd5ForData()", () =>
|
||||
{
|
||||
expect(hashUtil.generateMd5ForData("test")).toBe("098f6bcd4621d373cade4e832627b4f6");
|
||||
expect(hashUtil.generateMd5ForData("longerString12345678910")).toBe("c3e76c3c118c14e357e61ae1dbad4cf7");
|
||||
});
|
||||
});
|
@ -1,205 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||
import { TestHelper } from "../common/TestHelper";
|
||||
|
||||
let testHelper: TestHelper;
|
||||
|
||||
describe("test text", () =>
|
||||
{
|
||||
beforeAll(async () =>
|
||||
{
|
||||
testHelper = await TestHelper.fetchTestHelper();
|
||||
});
|
||||
|
||||
let itemHelper: ItemHelper;
|
||||
beforeEach(() =>
|
||||
{
|
||||
itemHelper = testHelper.getTestItemHelper();
|
||||
});
|
||||
|
||||
it("ItemHelper type check", () =>
|
||||
{
|
||||
expect(itemHelper).toBeInstanceOf(ItemHelper);
|
||||
});
|
||||
|
||||
it("isDogtag() usec", () =>
|
||||
{
|
||||
expect(itemHelper.isDogtag("59f32c3b86f77472a31742f0")).toBe(true);
|
||||
});
|
||||
|
||||
it("isDogtag() bear", () =>
|
||||
{
|
||||
expect(itemHelper.isDogtag("59f32bb586f774757e1e8442")).toBe(true);
|
||||
});
|
||||
|
||||
it("isValidItem() valid item screwdriver", () =>
|
||||
{
|
||||
expect(itemHelper.isValidItem("590c2d8786f774245b1f03f3")).toBe(true); // screwdriver
|
||||
});
|
||||
|
||||
it("isValidItem() invalid item tool base item", () =>
|
||||
{
|
||||
expect(itemHelper.isValidItem("57864bb7245977548b3b66c2")).toBe(false); // tool base item
|
||||
});
|
||||
|
||||
it("isValidItem() invalid item tpl", () =>
|
||||
{
|
||||
expect(itemHelper.isValidItem("fakeitem")).toBe(false);
|
||||
});
|
||||
|
||||
it("isValidItem() valid item with base type in blacklist", () =>
|
||||
{
|
||||
expect(itemHelper.isValidItem("5b3f3af486f774679e752c1f", [BaseClasses.ARMBAND])).toBe(false);
|
||||
});
|
||||
|
||||
it("getItemPrice() valid screwdriver item", () =>
|
||||
{
|
||||
expect(itemHelper.getItemPrice("590c2d8786f774245b1f03f3")).toBe(3500); // screwdriver
|
||||
});
|
||||
|
||||
it("getItemPrice() invalid tpl forces return of 0 price", () =>
|
||||
{
|
||||
expect(itemHelper.getItemPrice("fakeitem")).toBe(0);
|
||||
});
|
||||
|
||||
it("fixItemStackCount() item with no upd object", () =>
|
||||
{
|
||||
const itemWithNoUpd: Item = { _id: "test", _tpl: "123456789" };
|
||||
const result = itemHelper.fixItemStackCount(itemWithNoUpd);
|
||||
expect(result.upd?.StackObjectsCount).toBe(1);
|
||||
});
|
||||
|
||||
it("fixItemStackCount() item with upd object no StackObjectsCount property", () =>
|
||||
{
|
||||
const itemWithUpdNoStack: Item = { _id: "test", _tpl: "123456789", upd: {} };
|
||||
const result = itemHelper.fixItemStackCount(itemWithUpdNoStack);
|
||||
expect(result.upd?.StackObjectsCount).toBe(1);
|
||||
});
|
||||
|
||||
it("fixItemStackCount() item with upd object and custom stack count", () =>
|
||||
{
|
||||
const itemWithUpdAndStack: Item = { _id: "test", _tpl: "123456789", upd: { StackObjectsCount: 2 } };
|
||||
const result = itemHelper.fixItemStackCount(itemWithUpdAndStack);
|
||||
expect(result.upd?.StackObjectsCount).toBe(2);
|
||||
});
|
||||
|
||||
it("getItemStackSize() stack size of 4", () =>
|
||||
{
|
||||
const itemWithStackSizeOf4: Item = { _id: "", _tpl: "", upd: { StackObjectsCount: 4 } };
|
||||
const result = itemHelper.getItemStackSize(itemWithStackSizeOf4);
|
||||
expect(result).toBe(4);
|
||||
});
|
||||
|
||||
it("getItemStackSize() upd object no stack property", () =>
|
||||
{
|
||||
const itemWithUpdNoStack: Item = { _id: "", _tpl: "", upd: {} };
|
||||
const result = itemHelper.getItemStackSize(itemWithUpdNoStack);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
|
||||
it("getItemStackSize() no upd object", () =>
|
||||
{
|
||||
const itemWithNoUpdObject: Item = { _id: "", _tpl: "" };
|
||||
const result = itemHelper.getItemStackSize(itemWithNoUpdObject);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
|
||||
it("getItemQualityModifier() no upd object", () =>
|
||||
{
|
||||
const itemWithNoUpdObject: Item = { _id: "", _tpl: "" };
|
||||
const result = itemHelper.getItemQualityModifier(itemWithNoUpdObject);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
|
||||
it("getItemQualityModifier() grizzly medkit with full hp", () =>
|
||||
{
|
||||
const medkitItem: Item = { _id: "", _tpl: "590c657e86f77412b013051d", upd: { MedKit: { HpResource: 1800 } } };
|
||||
const result = itemHelper.getItemQualityModifier(medkitItem);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
|
||||
it("getItemQualityModifier() grizzly medkit with 0 hp", () =>
|
||||
{
|
||||
const medkitItem: Item = { _id: "", _tpl: "590c657e86f77412b013051d", upd: { MedKit: { HpResource: 0 } } };
|
||||
const result = itemHelper.getItemQualityModifier(medkitItem);
|
||||
expect(result).toBe(0.01);
|
||||
});
|
||||
|
||||
it("getItemQualityModifier() repairable slick with full hp", () =>
|
||||
{
|
||||
const medkitItem: Item = {
|
||||
_id: "",
|
||||
_tpl: "5e4abb5086f77406975c9342",
|
||||
upd: { Repairable: { Durability: 80, MaxDurability: 80 } },
|
||||
};
|
||||
const result = itemHelper.getItemQualityModifier(medkitItem);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
|
||||
it("getItemQualityModifier() repairable slick with 0 hp", () =>
|
||||
{
|
||||
const medkitItem: Item = {
|
||||
_id: "",
|
||||
_tpl: "5e4abb5086f77406975c9342",
|
||||
upd: { Repairable: { Durability: 0, MaxDurability: 80 } },
|
||||
};
|
||||
const result = itemHelper.getItemQualityModifier(medkitItem);
|
||||
expect(result).toBe(0.01);
|
||||
});
|
||||
|
||||
it("getRepairableItemQualityValue() repairable MDR weapon with max durability", () =>
|
||||
{
|
||||
const mdrItem: Item = {
|
||||
_id: "",
|
||||
_tpl: "5c488a752e221602b412af63",
|
||||
upd: { Repairable: { Durability: 100, MaxDurability: 100 } },
|
||||
};
|
||||
|
||||
const result = itemHelper.getItemQualityModifier(mdrItem);
|
||||
expect(result).toBe(1);
|
||||
});
|
||||
|
||||
it("hasBuyRestrictions() item with restrictions, not reached", () =>
|
||||
{
|
||||
const item: Item = { _id: "", _tpl: "", upd: { BuyRestrictionCurrent: 0, BuyRestrictionMax: 5 } };
|
||||
|
||||
const result = itemHelper.hasBuyRestrictions(item);
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("hasBuyRestrictions() item no restrictions defined", () =>
|
||||
{
|
||||
const item: Item = { _id: "", _tpl: "", upd: {} };
|
||||
|
||||
const result = itemHelper.hasBuyRestrictions(item);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("doesItemOrParentsIdMatch() item doesnt exist", () =>
|
||||
{
|
||||
const result = itemHelper.doesItemOrParentsIdMatch("fakeTpl", []);
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("isQuestItem() item is quest item", () =>
|
||||
{
|
||||
const result = itemHelper.isQuestItem("5ae9a3f586f7740aab00e4e6");
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("isQuestItem() item is not quest item", () =>
|
||||
{
|
||||
const result = itemHelper.isQuestItem("590c392f86f77444754deb29");
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("isQuestItem() invalid item tpl", () =>
|
||||
{
|
||||
const result = itemHelper.isQuestItem("faketpl");
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
@ -1,51 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
|
||||
import { RandomUtil } from "@spt-aki/utils/RandomUtil";
|
||||
import { TestHelper } from "../common/TestHelper";
|
||||
|
||||
const testHelper = new TestHelper();
|
||||
|
||||
const logger = testHelper.getTestLogger();
|
||||
const jsonUtil = testHelper.getTestJsonUtil();
|
||||
|
||||
describe("test text", () =>
|
||||
{
|
||||
let randomUtil: RandomUtil;
|
||||
beforeEach(() =>
|
||||
{
|
||||
randomUtil = new RandomUtil(jsonUtil, logger);
|
||||
});
|
||||
|
||||
it("RandomUtil type check", () =>
|
||||
{
|
||||
expect(randomUtil).toBeInstanceOf(RandomUtil);
|
||||
});
|
||||
|
||||
it("getInt()", () =>
|
||||
{
|
||||
expect(randomUtil.getInt(1, 1)).toBe(1);
|
||||
expect(randomUtil.getInt(100, 100)).toBe(100);
|
||||
expect([256, 257, 258, 259, 260, 261]).toContain(randomUtil.getInt(256, 261));
|
||||
});
|
||||
|
||||
it("getIntEx()", () =>
|
||||
{
|
||||
expect(randomUtil.getIntEx(1)).toBe(1);
|
||||
expect([1, 2, 3]).toContain(randomUtil.getIntEx(5));
|
||||
expect([1, 2, 3, 4, 5, 6, 7, 8]).toContain(randomUtil.getIntEx(10));
|
||||
});
|
||||
|
||||
it("getFloat()", () =>
|
||||
{
|
||||
const zeroToOneFloat = randomUtil.getFloat(0, 1);
|
||||
expect(zeroToOneFloat).toBeGreaterThanOrEqual(0);
|
||||
expect(zeroToOneFloat).toBeLessThan(1);
|
||||
});
|
||||
|
||||
it("getBool()", () =>
|
||||
{
|
||||
expect([true, false]).toContain(randomUtil.getBool());
|
||||
});
|
||||
});
|
@ -1,74 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
|
||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||
|
||||
describe("test text", () =>
|
||||
{
|
||||
let timeUtil: TimeUtil;
|
||||
beforeEach(() =>
|
||||
{
|
||||
timeUtil = new TimeUtil();
|
||||
});
|
||||
|
||||
it("BotHelper type check", () =>
|
||||
{
|
||||
expect(timeUtil).toBeInstanceOf(TimeUtil);
|
||||
});
|
||||
|
||||
it("formatTime()", () =>
|
||||
{
|
||||
expect(timeUtil.formatTime(new Date(2020, 1, 1, 15, 24, 0))).toBe("15-24-00");
|
||||
});
|
||||
|
||||
it("formatDate()", () =>
|
||||
{
|
||||
expect(timeUtil.formatDate(new Date(2020, 4, 13))).toBe("2020-05-13");
|
||||
});
|
||||
|
||||
it("getDate()", () =>
|
||||
{
|
||||
const currentDate = timeUtil.formatDate(new Date());
|
||||
expect(timeUtil.getDate()).toBe(currentDate);
|
||||
});
|
||||
|
||||
it("getTime()", () =>
|
||||
{
|
||||
const currentTime = timeUtil.formatTime(new Date());
|
||||
expect(timeUtil.getTime()).toBe(currentTime);
|
||||
});
|
||||
|
||||
it("getHoursAsSeconds() one hour", () =>
|
||||
{
|
||||
expect(timeUtil.getHoursAsSeconds(1)).toBe(3600);
|
||||
});
|
||||
|
||||
it("getHoursAsSeconds() three hours", () =>
|
||||
{
|
||||
expect(timeUtil.getHoursAsSeconds(3)).toBe(10800);
|
||||
});
|
||||
|
||||
it("getTimestamp()", () =>
|
||||
{
|
||||
const currentTimestampSecondsFloored = Math.floor(new Date().getTime() / 1000);
|
||||
expect(timeUtil.getTimestamp()).toBe(currentTimestampSecondsFloored);
|
||||
});
|
||||
|
||||
it("getTimeMailFormat()", () =>
|
||||
{
|
||||
const currentTime = new Date();
|
||||
const currentTimeMinutes = (currentTime.getMinutes()).toString().padStart(2, "0");
|
||||
const currentTimeHours = (currentTime.getHours()).toString().padStart(2, "0");
|
||||
expect(timeUtil.getTimeMailFormat()).toBe(`${currentTimeHours}:${currentTimeMinutes}`);
|
||||
});
|
||||
|
||||
it("getDateMailFormat()", () =>
|
||||
{
|
||||
const currentTime = new Date();
|
||||
const currentDay = (currentTime.getDate()).toString().padStart(2, "0");
|
||||
const currentMonth = (currentTime.getMonth() + 1).toString().padStart(2, "0");
|
||||
const currentYear = currentTime.getFullYear();
|
||||
expect(timeUtil.getDateMailFormat()).toBe(`${currentDay}.${currentMonth}.${currentYear}`);
|
||||
});
|
||||
});
|
@ -1,28 +0,0 @@
|
||||
import "reflect-metadata";
|
||||
|
||||
import { beforeEach, describe, expect, it } from "@jest/globals";
|
||||
import { UUidGenerator } from "@spt-aki/utils/UUidGenerator";
|
||||
import { TestHelper } from "../common/TestHelper";
|
||||
|
||||
const testHelper = new TestHelper();
|
||||
|
||||
describe("test text", () =>
|
||||
{
|
||||
let uuidGenerator: UUidGenerator;
|
||||
beforeEach(() =>
|
||||
{
|
||||
uuidGenerator = testHelper.getTestUuidGenerator();
|
||||
});
|
||||
|
||||
it("UUidGenerator type check", () =>
|
||||
{
|
||||
expect(uuidGenerator).toBeInstanceOf(UUidGenerator);
|
||||
});
|
||||
|
||||
it("generate()", () =>
|
||||
{
|
||||
expect(uuidGenerator.generate()).toHaveLength(36);
|
||||
expect(uuidGenerator.generate()).toContain("-");
|
||||
expect(uuidGenerator.generate()).toContain("4");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user