Skip to content

Commit

Permalink
fix(item-preview): fix itemset and related unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Helias committed Apr 2, 2020
1 parent 0d80aaa commit 2ec889c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ describe('ItemPreviewService', () => {
const mockItems4 = [{ id: 152, slotBak: 1, itemset: 152 }];
const mockItems5 = [{ id: 153, slotBak: 1, itemset: 153 }, { id: 153, slotBak: 2, itemset: 153 }];

const mockItemset1 = { id: 123, name: 'Helias itemset', spell1: 1, bonus1: 2, bonus2: 1, skillId: 1, skillLevel: 1 };
const mockItemset2 = { id: 123, name: 'Shin itemset', spell1: 1, spell2: 2, skillId: 1 };
const mockItemset3 = { id: 123, name: 'Kalhac itemset' };
const mockItemset4 = { id: 123, name: null };
const mockItemset1 = [{ id: 123, name: 'Helias itemset', spell1: 1, bonus1: 2, bonus2: 1, skillId: 1, skillLevel: 1 }];
const mockItemset2 = [{ id: 123, name: 'Shin itemset', spell1: 1, spell2: 2, skillId: 1 }];
const mockItemset3 = [{ id: 123, name: 'Kalhac itemset' }];
const mockItemset4 = [{ id: 123, name: null }];

const id = 123;

Expand Down
7 changes: 5 additions & 2 deletions src/app/features/item/item-template/item-preview.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,12 @@ export class ItemPreviewService {
itemsName[i] = itemsName[i].name ?? '';
}

const itemsetAttr = await this.getItemsetById(itemset);
let itemsetAttr = await this.getItemsetById(itemset);

if (!itemsetAttr || itemsName.join('') === '') {
if (!itemsetAttr || itemsName.join('') === '' || !itemsetAttr[0]) {
return '';
} else {
itemsetAttr = itemsetAttr[0];
}

itemsetText += '<br><br><span class="q">' + ITEM_CONSTANTS.setName
Expand Down Expand Up @@ -788,6 +790,7 @@ export class ItemPreviewService {
tmpBonus += `<br><span>${bonusText}</span>`;
}
}

if (tmpBonus !== '') {
itemsetText += `<span class="q0">${tmpBonus}</span>`;
}
Expand Down

0 comments on commit 2ec889c

Please sign in to comment.