mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-20 04:38:55 +00:00
handle error from invalid input
This commit is contained in:
parent
3313584d60
commit
c2b370f4d3
2 changed files with 11 additions and 1 deletions
|
|
@ -36,7 +36,7 @@ describe('shared.ops.unlock', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('does not unlock lost gear', async () => {
|
||||
it('does not unlock lost gear', async () => {
|
||||
user.items.gear.owned.headAccessory_special_bearEars = false;
|
||||
|
||||
await unlock(user, {
|
||||
|
|
@ -345,4 +345,13 @@ describe('shared.ops.unlock', () => {
|
|||
expect(get(user.purchased, backgroundUnlockPath)).to.be.true;
|
||||
expect(user.balance).to.equal(usersStartingGems - 1.75);
|
||||
});
|
||||
|
||||
it('handles an invalid hair path gracefully', async () => {
|
||||
try {
|
||||
await unlock(user, { query: { path: 'hair.invalid' } });
|
||||
} catch (err) {
|
||||
expect(err).to.be.an.instanceof(BadRequest);
|
||||
expect(err.message).to.equal(i18n.t('invalidUnlockSet'));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -36,6 +36,7 @@ function getItemByPath (path, setType) {
|
|||
if (setType === 'hair') {
|
||||
// itemPathParent is in this format: hair.purple
|
||||
const hairType = itemPathParent.split('.')[1];
|
||||
if (!content.appearances.hair[hairType]) return null;
|
||||
return content.appearances.hair[hairType][itemKey];
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue