From db1c2fd5a2480e2e7e7521038d7b59e60d5f98e8 Mon Sep 17 00:00:00 2001 From: SabreCat Date: Fri, 2 Jun 2017 15:28:28 +0000 Subject: [PATCH] fix(shops): don't push if empty Also corrects text on hatching potions --- test/common/libs/shops.js | 6 ++++++ website/common/script/content/index.js | 2 +- website/common/script/libs/shops.js | 12 ++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test/common/libs/shops.js b/test/common/libs/shops.js index 5def960c29..f3b5dce724 100644 --- a/test/common/libs/shops.js +++ b/test/common/libs/shops.js @@ -13,6 +13,12 @@ describe('shops', () => { expect(shopCategories.length).to.be.greaterThan(2); }); + it('does not contain an empty category', () => { + _.each(shopCategories, (category) => { + expect(category.items.length).to.be.greaterThan(0); + }); + }); + it('does not duplicate identifiers', () => { let identifiers = Array.from(new Set(shopCategories.map(cat => cat.identifier))); diff --git a/website/common/script/content/index.js b/website/common/script/content/index.js index 5ab0f91006..7665ff2375 100644 --- a/website/common/script/content/index.js +++ b/website/common/script/content/index.js @@ -65,7 +65,7 @@ api.bundles = { 'owl', ], canBuy () { - return moment().isBetween('2017-05-16', '2017-06-02'); + return moment().isBetween('2017-05-16', '2017-05-31'); }, type: 'quests', value: 7, diff --git a/website/common/script/libs/shops.js b/website/common/script/libs/shops.js index 1effbdc483..e92f1ffb73 100644 --- a/website/common/script/libs/shops.js +++ b/website/common/script/libs/shops.js @@ -55,7 +55,7 @@ shops.getMarketCategories = function getMarket (user, language) { .map(hatchingPotion => { return { key: hatchingPotion.key, - text: hatchingPotion.text(language), + text: i18n.t('potion', {potionType: hatchingPotion.text(language)}), notes: hatchingPotion.notes(language), class: `Pet_HatchingPotion_${hatchingPotion.key}`, value: hatchingPotion.value, @@ -76,7 +76,7 @@ shops.getMarketCategories = function getMarket (user, language) { .map(premiumHatchingPotion => { return { key: premiumHatchingPotion.key, - text: premiumHatchingPotion.text(language), + text: i18n.t('potion', {potionType: premiumHatchingPotion.text(language)}), notes: `${premiumHatchingPotion.notes(language)} ${premiumHatchingPotion._addlNotes(language)}`, class: `Pet_HatchingPotion_${premiumHatchingPotion.key}`, value: premiumHatchingPotion.value, @@ -85,7 +85,9 @@ shops.getMarketCategories = function getMarket (user, language) { purchaseType: 'hatchingPotions', }; }), 'key'); - categories.push(premiumHatchingPotionsCategory); + if (premiumHatchingPotionsCategory.items.length > 0) { + categories.push(premiumHatchingPotionsCategory); + } let foodCategory = { identifier: 'food', @@ -185,7 +187,9 @@ shops.getQuestShopCategories = function getQuestShopCategories (user, language) }; })); - categories.push(bundleCategory); + if (bundleCategory.items.length > 0) { + categories.push(bundleCategory); + } each(content.userCanOwnQuestCategories, type => { let category = {