test(inventory): cover the non-equippable branch of the detail panel
The panel's three-way actions block had no test for its middle branch: an item with equipmentSlot null should show "Nicht ausrüstbar" and no equip button. The gap predates this slice -- Task 14's review found it while confirming the removed level gate had not cost coverage. Deferred until now on purpose: the web bundle could not compile for the whole slice, so committing this earlier would have meant shipping a test I had never executed. Load-bearing: dropping the !isEquippable() guard would fall through to the else branch and render the button, failing the assertion. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,6 +37,23 @@ const banditBlade: InventoryItem = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ashPelt: InventoryItem = {
|
||||||
|
id: 'item-pelt',
|
||||||
|
quantity: 3,
|
||||||
|
equipped: false,
|
||||||
|
item: {
|
||||||
|
key: 'ash-pelt',
|
||||||
|
name: 'Aschenfell',
|
||||||
|
rarity: 'COMMON',
|
||||||
|
equipmentSlot: null,
|
||||||
|
weaponDamage: 0,
|
||||||
|
bonusAttack: 0,
|
||||||
|
bonusHp: 0,
|
||||||
|
bonusArmor: 0,
|
||||||
|
iconPath: '/images/items/ash-pelt.png',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
async function setup(overrides: {
|
async function setup(overrides: {
|
||||||
item?: InventoryItem | null;
|
item?: InventoryItem | null;
|
||||||
equippedItemInSlot?: InventoryItem | null;
|
equippedItemInSlot?: InventoryItem | null;
|
||||||
@@ -66,6 +83,15 @@ describe('InventoryDetailPanelComponent', () => {
|
|||||||
expect(element.querySelector('[data-detail-equip]')).toBeNull();
|
expect(element.querySelector('[data-detail-equip]')).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('refuses to offer an equip button for a non-equippable item', async () => {
|
||||||
|
const fixture = await setup({ item: ashPelt });
|
||||||
|
const element = fixture.nativeElement as HTMLElement;
|
||||||
|
|
||||||
|
expect(element.textContent).toContain('Nicht ausrüstbar');
|
||||||
|
expect(element.querySelector('[data-detail-equip]')).toBeNull();
|
||||||
|
expect(element.querySelector('[data-detail-equipped]')).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
it('shows the stat comparison against the equipped item in the same slot', async () => {
|
it('shows the stat comparison against the equipped item in the same slot', async () => {
|
||||||
const fixture = await setup({ item: banditBlade, equippedItemInSlot: wornSword });
|
const fixture = await setup({ item: banditBlade, equippedItemInSlot: wornSword });
|
||||||
const text = (fixture.nativeElement as HTMLElement).querySelector('[data-detail-stats]')?.textContent ?? '';
|
const text = (fixture.nativeElement as HTMLElement).querySelector('[data-detail-stats]')?.textContent ?? '';
|
||||||
|
|||||||
Reference in New Issue
Block a user