From 52e4b9aeff1569db9106867fae7ec34e3bedd112 Mon Sep 17 00:00:00 2001 From: y0m0 Date: Wed, 12 Jul 2017 22:23:26 +0100 Subject: [PATCH] Fix TexttestFixture - broken after last commit which updates gilded_rose.js to use ES2015 class syntax - creates instance of class Shop - creates items array - updates showItemsFor --- js/TexttestFixture.html | 13 +++++++++---- js/src/gilded_rose.js | 14 +++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/js/TexttestFixture.html b/js/TexttestFixture.html index cf453495..0fa50cb9 100644 --- a/js/TexttestFixture.html +++ b/js/TexttestFixture.html @@ -12,6 +12,8 @@ $('body').append('

OMGHAI!

'); + items = []; + items.push(new Item('+5 Dexterity Vest', 10, 20)); items.push(new Item('Aged Brie', 2, 0)); items.push(new Item('Elixir of the Mongoose', 5, 7)); @@ -23,12 +25,15 @@ // this conjured item does not work properly yet items.push(new Item('Conjured Mana Cake', 3, 6)); + + gildedRose = new Shop(items); + var days = 2; for (var i = 0; i < days; i++) { showHeaderFor(i); showItemsFor(i); - update_quality(); + gildedRose.updateQuality(); } function showHeaderFor(day) { @@ -37,9 +42,9 @@ function showItemsFor(day) { $('body').append('

name, sellIn, quality

'); - for (var j = 0; j < items.length; j++) { - var item = items[j]; - $('body').append('

' + item.name + ', ' + item.sell_in + ', ' + item.quality + '

'); + for (var j = 0; j < gildedRose.items.length; j++) { + var item = gildedRose.items[j]; + $('body').append('

' + item.name + ', ' + item.sellIn + ', ' + item.quality + '

'); } $('body').append('
'); } diff --git a/js/src/gilded_rose.js b/js/src/gilded_rose.js index 0bbba286..5358125e 100644 --- a/js/src/gilded_rose.js +++ b/js/src/gilded_rose.js @@ -15,21 +15,21 @@ class Shop { if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') { if (this.items[i].quality > 0) { if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { - this.items[i].quality = this.items[i].quality - 1 + this.items[i].quality = this.items[i].quality - 1; } } } else { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 + this.items[i].quality = this.items[i].quality + 1; if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') { if (this.items[i].sellIn < 11) { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 + this.items[i].quality = this.items[i].quality + 1; } } if (this.items[i].sellIn < 6) { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 + this.items[i].quality = this.items[i].quality + 1; } } } @@ -43,15 +43,15 @@ class Shop { if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') { if (this.items[i].quality > 0) { if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { - this.items[i].quality = this.items[i].quality - 1 + this.items[i].quality = this.items[i].quality - 1; } } } else { - this.items[i].quality = this.items[i].quality - this.items[i].quality + this.items[i].quality = this.items[i].quality - this.items[i].quality; } } else { if (this.items[i].quality < 50) { - this.items[i].quality = this.items[i].quality + 1 + this.items[i].quality = this.items[i].quality + 1; } } }