You've already forked tf2wikipricing
test: add botkiller detection tests
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { describe, expect, test, mock } from "bun:test";
|
import { describe, expect, test, mock } from "bun:test";
|
||||||
import { ItemSchema, ItemSlot, getItemIndexByName, getTradableStatusByDefindex, getTradableStatusByName, linkFestiveVariants, prepareSchema } from '../src/content/schemaService'
|
import { ItemSchema, ItemSlot, getItemIndexByName, getTradableStatusByDefindex, getTradableStatusByName, linkBotkillerVariants, linkFestiveVariants, prepareSchema } from '../src/content/schemaService'
|
||||||
|
|
||||||
// Mock the storage and log functions
|
// Mock the storage and log functions
|
||||||
mock.module('../src/content/storage', () => ({
|
mock.module('../src/content/storage', () => ({
|
||||||
@@ -20,7 +20,8 @@ const mockSchema: ItemSchema = {
|
|||||||
tradable: false,
|
tradable: false,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: true,
|
canKillstreakify: true,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
},
|
},
|
||||||
'208': {
|
'208': {
|
||||||
name: 'Flame Thrower',
|
name: 'Flame Thrower',
|
||||||
@@ -28,7 +29,8 @@ const mockSchema: ItemSchema = {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: true,
|
hasAustraliumVariant: true,
|
||||||
canKillstreakify: true,
|
canKillstreakify: true,
|
||||||
festiveVariant: 659
|
festiveVariant: 659,
|
||||||
|
botkillerVariants: [798, 807]
|
||||||
},
|
},
|
||||||
'659': {
|
'659': {
|
||||||
name: 'Festive Flame Thrower',
|
name: 'Festive Flame Thrower',
|
||||||
@@ -36,7 +38,26 @@ const mockSchema: ItemSchema = {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: true,
|
canKillstreakify: true,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
|
},
|
||||||
|
'798': {
|
||||||
|
name: 'Silver Botkiller Flame Thrower Mk.I',
|
||||||
|
slot: ItemSlot.Primary,
|
||||||
|
tradable: true,
|
||||||
|
hasAustraliumVariant: false,
|
||||||
|
canKillstreakify: true,
|
||||||
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
|
},
|
||||||
|
'807': {
|
||||||
|
name: 'Gold Botkiller Flame Thrower Mk.I',
|
||||||
|
slot: ItemSlot.Primary,
|
||||||
|
tradable: true,
|
||||||
|
hasAustraliumVariant: false,
|
||||||
|
canKillstreakify: true,
|
||||||
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
},
|
},
|
||||||
'5021': {
|
'5021': {
|
||||||
name: 'Mann Co. Supply Crate Key',
|
name: 'Mann Co. Supply Crate Key',
|
||||||
@@ -44,7 +65,8 @@ const mockSchema: ItemSchema = {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: false,
|
canKillstreakify: false,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
},
|
},
|
||||||
'15141': {
|
'15141': {
|
||||||
name: 'Flame Thrower',
|
name: 'Flame Thrower',
|
||||||
@@ -52,7 +74,8 @@ const mockSchema: ItemSchema = {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: true,
|
canKillstreakify: true,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
},
|
},
|
||||||
'69420': {
|
'69420': {
|
||||||
name: 'Non-Tradable Item',
|
name: 'Non-Tradable Item',
|
||||||
@@ -60,7 +83,8 @@ const mockSchema: ItemSchema = {
|
|||||||
tradable: false,
|
tradable: false,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: false,
|
canKillstreakify: false,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +164,8 @@ describe('Schema Service', () => {
|
|||||||
tradable: false,
|
tradable: false,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: false,
|
canKillstreakify: false,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
},
|
},
|
||||||
'208': { // Original Flame Thrower
|
'208': { // Original Flame Thrower
|
||||||
name: 'Flame Thrower',
|
name: 'Flame Thrower',
|
||||||
@@ -148,7 +173,8 @@ describe('Schema Service', () => {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: true,
|
hasAustraliumVariant: true,
|
||||||
canKillstreakify: true,
|
canKillstreakify: true,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
},
|
},
|
||||||
'659': { // Festive Flame Thrower (should be detected)
|
'659': { // Festive Flame Thrower (should be detected)
|
||||||
name: 'Festive Flame Thrower',
|
name: 'Festive Flame Thrower',
|
||||||
@@ -156,7 +182,8 @@ describe('Schema Service', () => {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: true,
|
canKillstreakify: true,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
},
|
},
|
||||||
'15141': { // Decorated (should be ignored)
|
'15141': { // Decorated (should be ignored)
|
||||||
name: 'Flame Thrower',
|
name: 'Flame Thrower',
|
||||||
@@ -164,7 +191,8 @@ describe('Schema Service', () => {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: true,
|
canKillstreakify: true,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const mockResponseItems = [
|
const mockResponseItems = [
|
||||||
@@ -188,7 +216,8 @@ describe('Schema Service', () => {
|
|||||||
tradable: true,
|
tradable: true,
|
||||||
hasAustraliumVariant: false,
|
hasAustraliumVariant: false,
|
||||||
canKillstreakify: false,
|
canKillstreakify: false,
|
||||||
festiveVariant: null
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -201,4 +230,111 @@ describe('Schema Service', () => {
|
|||||||
expect(testSchema['163'].festiveVariant).toBeNull();
|
expect(testSchema['163'].festiveVariant).toBeNull();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('linkBotkillerVariants', () => {
|
||||||
|
test('should link botkiller variants to their original counterparts', () => {
|
||||||
|
const testSchema = {
|
||||||
|
'21': { // Original Rocket Launcher
|
||||||
|
name: 'Flame Thrower',
|
||||||
|
slot: ItemSlot.Primary,
|
||||||
|
tradable: false,
|
||||||
|
hasAustraliumVariant: false,
|
||||||
|
canKillstreakify: false,
|
||||||
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
|
},
|
||||||
|
'208': { // Original Flame Thrower
|
||||||
|
name: 'Flame Thrower',
|
||||||
|
slot: ItemSlot.Primary,
|
||||||
|
tradable: true,
|
||||||
|
hasAustraliumVariant: true,
|
||||||
|
canKillstreakify: true,
|
||||||
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
|
},
|
||||||
|
'798': {
|
||||||
|
name: 'Silver Botkiller Flame Thrower Mk. I',
|
||||||
|
slot: ItemSlot.Primary,
|
||||||
|
tradable: true,
|
||||||
|
hasAustraliumVariant: false,
|
||||||
|
canKillstreakify: true,
|
||||||
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
|
},
|
||||||
|
'807': {
|
||||||
|
name: 'Gold Botkiller Flame Thrower Mk. I',
|
||||||
|
slot: ItemSlot.Primary,
|
||||||
|
tradable: true,
|
||||||
|
hasAustraliumVariant: false,
|
||||||
|
canKillstreakify: true,
|
||||||
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
|
},
|
||||||
|
'15141': { // Decorated (should be ignored)
|
||||||
|
name: 'Flame Thrower',
|
||||||
|
slot: ItemSlot.Primary,
|
||||||
|
tradable: true,
|
||||||
|
hasAustraliumVariant: false,
|
||||||
|
canKillstreakify: true,
|
||||||
|
festiveVariant: null,
|
||||||
|
botkillerVariants: null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const mockResponseItems = [
|
||||||
|
{ item_class: 'tf_weapon_flamethrower', defindex: 21, item_name: 'Flame Thrower', item_type_name: 'Flame Thrower'
|
||||||
|
}, // Incorrect; stock
|
||||||
|
{
|
||||||
|
item_class: 'tf_weapon_flamethrower',
|
||||||
|
defindex: 208,
|
||||||
|
item_name: 'Flame Thrower',
|
||||||
|
item_type_name: 'Flame Thrower'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
item_class: 'tf_weapon_flamethrower',
|
||||||
|
defindex: 798,
|
||||||
|
item_name: 'Silver Botkiller Flame Thrower Mk.I',
|
||||||
|
item_type_name: 'Flame Thrower'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
item_class: 'tf_weapon_flamethrower',
|
||||||
|
defindex: 807,
|
||||||
|
item_name: 'Gold Botkiller Flame Thrower Mk.I',
|
||||||
|
item_type_name: 'Flame Thrower'
|
||||||
|
},
|
||||||
|
{ item_class: 'tf_weapon_flamethrower', defindex: 15141, item_name: 'Flame Thrower', item_type_name: 'Flame Thrower' }, // Incorrect; decorated
|
||||||
|
];
|
||||||
|
linkBotkillerVariants(mockResponseItems, testSchema);
|
||||||
|
expect(testSchema['21'].botkillerVariants).toBeNull()
|
||||||
|
expect(testSchema['208'].botkillerVariants).toEqual([798, 807]);
|
||||||
|
expect(testSchema['798'].botkillerVariants).toBeNull();
|
||||||
|
expect(testSchema['807'].botkillerVariants).toBeNull();
|
||||||
|
expect(testSchema['15141'].botkillerVariants).toBeNull()
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should not link if no botkiller variants exist', () => {
|
||||||
|
const testSchema = {
|
||||||
|
'163': { // Crit-a-Cola
|
||||||
|
name: 'Crit-a-Cola',
|
||||||
|
slot: ItemSlot.Secondary,
|
||||||
|
tradable: true,
|
||||||
|
hasAustraliumVariant: false,
|
||||||
|
festiveVariant: null,
|
||||||
|
canKillstreakify: false,
|
||||||
|
botkillerVariants: null,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const mockResponseItems = [
|
||||||
|
{
|
||||||
|
item_class: 'tf_weapon_lunchbox_drink',
|
||||||
|
defindex: 163,
|
||||||
|
item_name: 'Crit-a-Cola',
|
||||||
|
item_type_name: 'Lunch Box',
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
linkBotkillerVariants(mockResponseItems, testSchema);
|
||||||
|
expect(testSchema['163'].botkillerVariants).toBeNull();
|
||||||
|
});
|
||||||
|
})
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user