step 10.13: done
This commit is contained in:
@@ -84,7 +84,7 @@ describe('hero profile (public)', () => {
|
||||
assert.ok(typeof data.int === 'number');
|
||||
assert.ok(typeof data.vit === 'number');
|
||||
assert.ok(typeof data.xp === 'number');
|
||||
assert.deepStrictEqual(data.equipment, { weapon: null, armor: null, trinket: null });
|
||||
assert.deepStrictEqual(data.equipment, { weapon: 'Rusty Sword', armor: null, trinket: null });
|
||||
|
||||
// Response must NOT contain private fields.
|
||||
assert.ok(!('energy' in data));
|
||||
@@ -98,26 +98,28 @@ describe('hero profile (public)', () => {
|
||||
const cookie = await registerAndLogin(`herouser2`, 'password123');
|
||||
const characterId = await createHero(cookie, 'ArmoredOne', 'mage');
|
||||
|
||||
// Insert starter gear directly into inventory (starter gear not auto-created yet).
|
||||
// Mage already has Apprentice Staff (item 2) equipped from starter kit.
|
||||
// Insert an armor item and equip it to test equipped item names.
|
||||
const db = require('../../src/db').getDb();
|
||||
|
||||
// Get a weapon item from the items table.
|
||||
const weapon = db.prepare(
|
||||
"SELECT id FROM items WHERE type = 'weapon' AND min_level <= 1 ORDER BY id LIMIT 1"
|
||||
// Get an armor item from the items table.
|
||||
const armor = db.prepare(
|
||||
"SELECT id FROM items WHERE type = 'armor' AND min_level <= 1 ORDER BY id LIMIT 1"
|
||||
).get();
|
||||
assert.ok(weapon, 'Should have a level-1 weapon in the items table');
|
||||
assert.ok(armor, 'Should have a level-1 armor in the items table');
|
||||
|
||||
// Insert it into inventory, equipped as weapon.
|
||||
// Insert it into inventory, equipped as armor.
|
||||
const now = Date.now();
|
||||
db.prepare(
|
||||
'INSERT INTO inventory (character_id, item_id, quantity, equipped_slot, acquired_at) VALUES (?, ?, 1, ?, ?)'
|
||||
).run(characterId, weapon.id, 'weapon', now);
|
||||
).run(characterId, armor.id, 'armor', now);
|
||||
|
||||
const res = await fetch(`${baseUrl}/api/heroes/ArmoredOne`);
|
||||
assert.equal(res.status, 200);
|
||||
const json = await res.json();
|
||||
assert.equal(json.ok, true);
|
||||
assert.ok(json.data.equipment.weapon, 'Should have a weapon equipped');
|
||||
assert.ok(json.data.equipment.armor, 'Should have armor equipped');
|
||||
});
|
||||
|
||||
it('is case-insensitive', async () => {
|
||||
|
||||
Reference in New Issue
Block a user