mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 02:30:43 -05:00
Add tests for getRandomCompatibleCaliberTemplateId()
This commit is contained in:
parent
c90f9499b1
commit
262c8a6e83
@ -6,6 +6,7 @@ import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||
import { Item, Repairable } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { HashUtil } from "@spt-aki/utils/HashUtil";
|
||||
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
||||
|
||||
describe("ItemHelper", () =>
|
||||
{
|
||||
@ -1072,4 +1073,52 @@ describe("ItemHelper", () =>
|
||||
expect(result.length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("getRandomCompatibleCaliberTemplateId", () =>
|
||||
{
|
||||
it("Should return an item from the passed in items Filter array", () =>
|
||||
{
|
||||
const fakeTemplateItem = {
|
||||
_props: {
|
||||
Cartridges: [
|
||||
{
|
||||
_props: {
|
||||
filters: [
|
||||
{
|
||||
Filter: [
|
||||
"desiredItemTpl"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
const result = itemHelper.getRandomCompatibleCaliberTemplateId(fakeTemplateItem as ITemplateItem);
|
||||
|
||||
expect(result).toBe("desiredItemTpl");
|
||||
});
|
||||
|
||||
it("Should return null when item passed in has empty cartridges data", () =>
|
||||
{
|
||||
const fakeTemplateItem = {
|
||||
_props: {
|
||||
Cartridges: [
|
||||
{}
|
||||
]
|
||||
}
|
||||
};
|
||||
const result = itemHelper.getRandomCompatibleCaliberTemplateId(fakeTemplateItem as ITemplateItem);
|
||||
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
|
||||
it("Should return null when undefined passed in", () =>
|
||||
{
|
||||
const result = itemHelper.getRandomCompatibleCaliberTemplateId(undefined as ITemplateItem);
|
||||
|
||||
expect(result).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user