mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 22:41:30 +00:00
refactor test
This commit is contained in:
parent
9e83d49374
commit
98c4fe782f
@ -46,6 +46,9 @@ export class GildedRose {
|
||||
case 'Backstage passes to a TAFKAL80ETC concert':
|
||||
this.updateBackstageProduct(item)
|
||||
return item
|
||||
case 'Conjured Mana Cake':
|
||||
this.updateConjuredProduct(item)
|
||||
return item
|
||||
default:
|
||||
this.updateNormalProduct(item)
|
||||
return item
|
||||
@ -54,22 +57,13 @@ export class GildedRose {
|
||||
}
|
||||
|
||||
private updateLegendaryProduct(item: Item) {
|
||||
item.sellIn = item.sellIn - 1
|
||||
item.quality = Item.legendaryQuality
|
||||
}
|
||||
|
||||
private updateAgedBrie(item: Item) {
|
||||
//
|
||||
item.sellIn = item.sellIn - 1
|
||||
|
||||
item.quality = this.incrementQuality(item)
|
||||
|
||||
if (!this.isOutdated(item)) {
|
||||
return
|
||||
}
|
||||
|
||||
item.quality = this.incrementQuality(item)
|
||||
|
||||
return { ...item, sellIn: item.sellIn - 1, quality: 0 }
|
||||
}
|
||||
|
||||
private updateBackstageProduct(item: Item) {
|
||||
@ -97,4 +91,13 @@ export class GildedRose {
|
||||
item.quality = this.decrementQuality(item)
|
||||
}
|
||||
}
|
||||
private updateConjuredProduct(item: Item) {
|
||||
item.sellIn = item.sellIn - 1
|
||||
item.quality = this.decrementQuality(item)
|
||||
item.quality = this.decrementQuality(item)
|
||||
if (this.isOutdated(item)) {
|
||||
item.quality = this.decrementQuality(item)
|
||||
item.quality = this.decrementQuality(item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,307 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 1`] = `"Day 1 - name: +5 Dexterity Vest quality: 20 sellIn: 10"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 2`] = `"Day 1 - name: Aged Brie quality: 1 sellIn: 1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 3`] = `"Day 1 - name: Elixir of the Mongoose quality: 5 sellIn: 3"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 4`] = `"Day 1 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 5`] = `"Day 1 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 6`] = `"Day 1 - name: Backstage passes to a TAFKAL80ETC concert quality: 25 sellIn: 10"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 7`] = `"Day 1 - name: Backstage passes to a TAFKAL80ETC concert quality: 50 sellIn: 4"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 8`] = `"Day 1 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -2"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 9`] = `"Day 1 - name: Conjured Mana Cake quality: 0 sellIn: -5"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 10`] = `"Day 2 - name: +5 Dexterity Vest quality: 11 sellIn: 1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 11`] = `"Day 2 - name: Aged Brie quality: 18 sellIn: -8"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 12`] = `"Day 2 - name: Elixir of the Mongoose quality: 0 sellIn: -6"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 13`] = `"Day 2 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 14`] = `"Day 2 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 15`] = `"Day 2 - name: Backstage passes to a TAFKAL80ETC concert quality: 47 sellIn: 1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 16`] = `"Day 2 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -5"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 17`] = `"Day 2 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -11"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 2 days 18`] = `"Day 2 - name: Conjured Mana Cake quality: 0 sellIn: -14"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 1`] = `"Day 1 - name: +5 Dexterity Vest quality: 0 sellIn: -8"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 2`] = `"Day 1 - name: Aged Brie quality: 36 sellIn: -17"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 3`] = `"Day 1 - name: Elixir of the Mongoose quality: 0 sellIn: -15"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 4`] = `"Day 1 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 5`] = `"Day 1 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 6`] = `"Day 1 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -8"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 7`] = `"Day 1 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -14"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 8`] = `"Day 1 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -20"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 9`] = `"Day 1 - name: Conjured Mana Cake quality: 0 sellIn: -23"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 10`] = `"Day 2 - name: +5 Dexterity Vest quality: 0 sellIn: -17"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 11`] = `"Day 2 - name: Aged Brie quality: 50 sellIn: -26"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 12`] = `"Day 2 - name: Elixir of the Mongoose quality: 0 sellIn: -24"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 13`] = `"Day 2 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 14`] = `"Day 2 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 15`] = `"Day 2 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -17"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 16`] = `"Day 2 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -23"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 17`] = `"Day 2 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -29"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 18`] = `"Day 2 - name: Conjured Mana Cake quality: 0 sellIn: -32"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 19`] = `"Day 3 - name: +5 Dexterity Vest quality: 0 sellIn: -26"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 20`] = `"Day 3 - name: Aged Brie quality: 50 sellIn: -35"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 21`] = `"Day 3 - name: Elixir of the Mongoose quality: 0 sellIn: -33"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 22`] = `"Day 3 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 23`] = `"Day 3 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 24`] = `"Day 3 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -26"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 25`] = `"Day 3 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -32"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 26`] = `"Day 3 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -38"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 27`] = `"Day 3 - name: Conjured Mana Cake quality: 0 sellIn: -41"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 28`] = `"Day 4 - name: +5 Dexterity Vest quality: 0 sellIn: -35"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 29`] = `"Day 4 - name: Aged Brie quality: 50 sellIn: -44"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 30`] = `"Day 4 - name: Elixir of the Mongoose quality: 0 sellIn: -42"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 31`] = `"Day 4 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 32`] = `"Day 4 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 33`] = `"Day 4 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -35"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 34`] = `"Day 4 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -41"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 35`] = `"Day 4 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -47"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 36`] = `"Day 4 - name: Conjured Mana Cake quality: 0 sellIn: -50"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 37`] = `"Day 5 - name: +5 Dexterity Vest quality: 0 sellIn: -44"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 38`] = `"Day 5 - name: Aged Brie quality: 50 sellIn: -53"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 39`] = `"Day 5 - name: Elixir of the Mongoose quality: 0 sellIn: -51"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 40`] = `"Day 5 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 41`] = `"Day 5 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 42`] = `"Day 5 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -44"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 43`] = `"Day 5 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -50"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 44`] = `"Day 5 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -56"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 45`] = `"Day 5 - name: Conjured Mana Cake quality: 0 sellIn: -59"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 46`] = `"Day 6 - name: +5 Dexterity Vest quality: 0 sellIn: -53"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 47`] = `"Day 6 - name: Aged Brie quality: 50 sellIn: -62"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 48`] = `"Day 6 - name: Elixir of the Mongoose quality: 0 sellIn: -60"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 49`] = `"Day 6 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 50`] = `"Day 6 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 51`] = `"Day 6 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -53"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 52`] = `"Day 6 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -59"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 53`] = `"Day 6 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -65"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 54`] = `"Day 6 - name: Conjured Mana Cake quality: 0 sellIn: -68"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 55`] = `"Day 7 - name: +5 Dexterity Vest quality: 0 sellIn: -62"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 56`] = `"Day 7 - name: Aged Brie quality: 50 sellIn: -71"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 57`] = `"Day 7 - name: Elixir of the Mongoose quality: 0 sellIn: -69"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 58`] = `"Day 7 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 59`] = `"Day 7 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 60`] = `"Day 7 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -62"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 61`] = `"Day 7 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -68"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 62`] = `"Day 7 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -74"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 63`] = `"Day 7 - name: Conjured Mana Cake quality: 0 sellIn: -77"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 64`] = `"Day 8 - name: +5 Dexterity Vest quality: 0 sellIn: -71"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 65`] = `"Day 8 - name: Aged Brie quality: 50 sellIn: -80"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 66`] = `"Day 8 - name: Elixir of the Mongoose quality: 0 sellIn: -78"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 67`] = `"Day 8 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 68`] = `"Day 8 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 69`] = `"Day 8 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -71"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 70`] = `"Day 8 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -77"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 71`] = `"Day 8 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -83"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 72`] = `"Day 8 - name: Conjured Mana Cake quality: 0 sellIn: -86"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 73`] = `"Day 9 - name: +5 Dexterity Vest quality: 0 sellIn: -80"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 74`] = `"Day 9 - name: Aged Brie quality: 50 sellIn: -89"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 75`] = `"Day 9 - name: Elixir of the Mongoose quality: 0 sellIn: -87"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 76`] = `"Day 9 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 77`] = `"Day 9 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 78`] = `"Day 9 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -80"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 79`] = `"Day 9 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -86"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 80`] = `"Day 9 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -92"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 81`] = `"Day 9 - name: Conjured Mana Cake quality: 0 sellIn: -95"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 82`] = `"Day 10 - name: +5 Dexterity Vest quality: 0 sellIn: -89"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 83`] = `"Day 10 - name: Aged Brie quality: 50 sellIn: -98"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 84`] = `"Day 10 - name: Elixir of the Mongoose quality: 0 sellIn: -96"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 85`] = `"Day 10 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 86`] = `"Day 10 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 87`] = `"Day 10 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -89"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 88`] = `"Day 10 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -95"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 89`] = `"Day 10 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -101"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 90`] = `"Day 10 - name: Conjured Mana Cake quality: 0 sellIn: -104"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 91`] = `"Day 11 - name: +5 Dexterity Vest quality: 0 sellIn: -98"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 92`] = `"Day 11 - name: Aged Brie quality: 50 sellIn: -107"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 93`] = `"Day 11 - name: Elixir of the Mongoose quality: 0 sellIn: -105"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 94`] = `"Day 11 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 95`] = `"Day 11 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 96`] = `"Day 11 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -98"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 97`] = `"Day 11 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -104"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 98`] = `"Day 11 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -110"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 99`] = `"Day 11 - name: Conjured Mana Cake quality: 0 sellIn: -113"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 100`] = `"Day 12 - name: +5 Dexterity Vest quality: 0 sellIn: -107"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 101`] = `"Day 12 - name: Aged Brie quality: 50 sellIn: -116"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 102`] = `"Day 12 - name: Elixir of the Mongoose quality: 0 sellIn: -114"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 103`] = `"Day 12 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 104`] = `"Day 12 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 105`] = `"Day 12 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -107"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 106`] = `"Day 12 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -113"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 107`] = `"Day 12 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -119"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 108`] = `"Day 12 - name: Conjured Mana Cake quality: 0 sellIn: -122"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 109`] = `"Day 13 - name: +5 Dexterity Vest quality: 0 sellIn: -116"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 110`] = `"Day 13 - name: Aged Brie quality: 50 sellIn: -125"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 111`] = `"Day 13 - name: Elixir of the Mongoose quality: 0 sellIn: -123"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 112`] = `"Day 13 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 113`] = `"Day 13 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 114`] = `"Day 13 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -116"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 115`] = `"Day 13 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -122"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 116`] = `"Day 13 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -128"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 117`] = `"Day 13 - name: Conjured Mana Cake quality: 0 sellIn: -131"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 118`] = `"Day 14 - name: +5 Dexterity Vest quality: 0 sellIn: -125"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 119`] = `"Day 14 - name: Aged Brie quality: 50 sellIn: -134"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 120`] = `"Day 14 - name: Elixir of the Mongoose quality: 0 sellIn: -132"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 121`] = `"Day 14 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 122`] = `"Day 14 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 123`] = `"Day 14 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -125"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 124`] = `"Day 14 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -131"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 125`] = `"Day 14 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -137"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 126`] = `"Day 14 - name: Conjured Mana Cake quality: 0 sellIn: -140"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 127`] = `"Day 15 - name: +5 Dexterity Vest quality: 0 sellIn: -134"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 128`] = `"Day 15 - name: Aged Brie quality: 50 sellIn: -143"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 129`] = `"Day 15 - name: Elixir of the Mongoose quality: 0 sellIn: -141"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 130`] = `"Day 15 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: 0"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 131`] = `"Day 15 - name: Sulfuras, Hand of Ragnaros quality: 80 sellIn: -1"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 132`] = `"Day 15 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -134"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 133`] = `"Day 15 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -140"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 134`] = `"Day 15 - name: Backstage passes to a TAFKAL80ETC concert quality: 0 sellIn: -146"`;
|
||||
|
||||
exports[`Gilded Rose should keep previous behavior for period of 15 days 135`] = `"Day 15 - name: Conjured Mana Cake quality: 0 sellIn: -149"`;
|
||||
@ -1,43 +1,160 @@
|
||||
import { Item, GildedRose } from '../gilded-rose'
|
||||
import { itemsGoldenMaster } from './golden-master-text-test'
|
||||
|
||||
describe('Gilded Rose', function () {
|
||||
it('should foo', function () {
|
||||
const gildedRose = new GildedRose([new Item('foo', 0, 0)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toMatchInlineSnapshot(`"foo"`)
|
||||
expect(items[0].quality).toMatchInlineSnapshot(`0`)
|
||||
expect(items[0].sellIn).toMatchInlineSnapshot(`-1`)
|
||||
describe('Gilded Rose: ', function () {
|
||||
describe('legendary product', () => {
|
||||
it('should always have 80 in quality', function () {
|
||||
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', 0, 80)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toBe('Sulfuras, Hand of Ragnaros')
|
||||
expect(items[0].quality).toBe(80)
|
||||
expect(items[0].sellIn).toBe(-1)
|
||||
gildedRose.updateQuality()
|
||||
expect(items[0].quality).toBe(80)
|
||||
expect(items[0].sellIn).toBe(-2)
|
||||
})
|
||||
})
|
||||
|
||||
describe('should keep previous behavior', () => {
|
||||
it('for period of 2 days', function () {
|
||||
const gildedRose = new GildedRose(itemsGoldenMaster)
|
||||
const days = 2
|
||||
for (let i = 0; i < days; i++) {
|
||||
itemsGoldenMaster.forEach(element => {
|
||||
expect(
|
||||
`Day ${i + 1} - name: ${element.name} quality: ${element.quality} sellIn: ${
|
||||
element.sellIn
|
||||
}`,
|
||||
).toMatchSnapshot()
|
||||
gildedRose.updateQuality()
|
||||
})
|
||||
}
|
||||
describe('Aged Brie product', () => {
|
||||
it('should grow in quality', function () {
|
||||
const gildedRose = new GildedRose([new Item('Aged Brie', 2, 10)])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.name).toBe('Aged Brie')
|
||||
expect(product.quality).toBe(11)
|
||||
expect(product.sellIn).toBe(1)
|
||||
})
|
||||
it('for period of 15 days', function () {
|
||||
const gildedRose = new GildedRose(itemsGoldenMaster)
|
||||
const days = 15
|
||||
for (let i = 0; i < days; i++) {
|
||||
itemsGoldenMaster.forEach(element => {
|
||||
expect(
|
||||
`Day ${i + 1} - name: ${element.name} quality: ${element.quality} sellIn: ${
|
||||
element.sellIn
|
||||
}`,
|
||||
).toMatchSnapshot()
|
||||
gildedRose.updateQuality()
|
||||
})
|
||||
}
|
||||
|
||||
it('quality should never go above 50', () => {
|
||||
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 50)])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.name).toBe('Aged Brie')
|
||||
expect(product.quality).toBe(50)
|
||||
expect(product.sellIn).toBe(0)
|
||||
})
|
||||
|
||||
it('should allow quality of outdated aged brie to be incremented up', () => {
|
||||
const gildedRose = new GildedRose([new Item('Aged Brie', -10, 10)])
|
||||
const items = gildedRose.updateQuality()
|
||||
const added = items[0]
|
||||
expect(added.quality).toBe(11)
|
||||
expect(added.sellIn).toBe(-11)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Backstage product', () => {
|
||||
it('should have growing in quality', function () {
|
||||
const gildedRose = new GildedRose([
|
||||
new Item('Backstage passes to a TAFKAL80ETC concert', 20, 20),
|
||||
])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.name).toBe('Backstage passes to a TAFKAL80ETC concert')
|
||||
expect(product.quality).toBe(21)
|
||||
expect(product.sellIn).toBe(19)
|
||||
})
|
||||
|
||||
it('quality should never go above 50', () => {
|
||||
const gildedRose = new GildedRose([
|
||||
new Item('Backstage passes to a TAFKAL80ETC concert', 30, 50),
|
||||
])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.name).toBe('Backstage passes to a TAFKAL80ETC concert')
|
||||
expect(product.quality).toBe(50)
|
||||
expect(product.sellIn).toBe(29)
|
||||
})
|
||||
|
||||
it('quality should grow by 2 when sellIn is lower than 11', () => {
|
||||
const gildedRose = new GildedRose([
|
||||
new Item('Backstage passes to a TAFKAL80ETC concert', 10, 10),
|
||||
])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.quality).toBe(12)
|
||||
expect(product.sellIn).toBe(9)
|
||||
})
|
||||
|
||||
it('quality should grow by 3 when sellIn is lower than 6', () => {
|
||||
const gildedRose = new GildedRose([
|
||||
new Item('Backstage passes to a TAFKAL80ETC concert', 5, 10),
|
||||
])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.quality).toBe(13)
|
||||
expect(product.sellIn).toBe(4)
|
||||
})
|
||||
|
||||
it('quality should be 0 when sellIn is 0 or lower', () => {
|
||||
const gildedRose = new GildedRose([
|
||||
new Item('Backstage passes to a TAFKAL80ETC concert', 1, 10),
|
||||
])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.quality).toBe(0)
|
||||
expect(product.sellIn).toBe(0)
|
||||
})
|
||||
|
||||
it('should not decrement below 0 in quality', () => {
|
||||
const gildedRose = new GildedRose([
|
||||
new Item('Backstage passes to a TAFKAL80ETC concert', 0, 10),
|
||||
])
|
||||
const items = gildedRose.updateQuality()
|
||||
const product = items[0]
|
||||
expect(product.quality).toBe(0)
|
||||
expect(product.sellIn).toBe(-1)
|
||||
})
|
||||
})
|
||||
describe('Normal product', () => {
|
||||
it('should decrement in quality each day', function () {
|
||||
const gildedRose = new GildedRose([new Item('foo', 10, 10)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toBe('foo')
|
||||
expect(items[0].quality).toBe(9)
|
||||
expect(items[0].sellIn).toBe(9)
|
||||
gildedRose.updateQuality()
|
||||
expect(items[0].quality).toBe(8)
|
||||
expect(items[0].sellIn).toBe(8)
|
||||
})
|
||||
it('should decrement x2 faster in quality each day when sellIn < 0', function () {
|
||||
const gildedRose = new GildedRose([new Item('foo', 0, 10)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toBe('foo')
|
||||
expect(items[0].quality).toBe(8)
|
||||
expect(items[0].sellIn).toBe(-1)
|
||||
gildedRose.updateQuality()
|
||||
expect(items[0].quality).toBe(6)
|
||||
expect(items[0].sellIn).toBe(-2)
|
||||
})
|
||||
it('should not decrement below 0 in quality', function () {
|
||||
const gildedRose = new GildedRose([new Item('foo', 0, 0)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toBe('foo')
|
||||
expect(items[0].quality).toBe(0)
|
||||
expect(items[0].sellIn).toBe(-1)
|
||||
})
|
||||
})
|
||||
describe('Conjured product', () => {
|
||||
it('should decrement 2 times faster than product in quality each day', function () {
|
||||
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 1, 6)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toBe('Conjured Mana Cake')
|
||||
expect(items[0].quality).toBe(4)
|
||||
expect(items[0].sellIn).toBe(0)
|
||||
})
|
||||
it('should decrement x4 faster in quality each day when sellIn < 0', function () {
|
||||
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 0, 6)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toBe('Conjured Mana Cake')
|
||||
expect(items[0].quality).toBe(2)
|
||||
expect(items[0].sellIn).toBe(-1)
|
||||
})
|
||||
it('should not decrement below 0 in quality', function () {
|
||||
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 0, 0)])
|
||||
const items = gildedRose.updateQuality()
|
||||
expect(items[0].name).toBe('Conjured Mana Cake')
|
||||
expect(items[0].quality).toBe(0)
|
||||
expect(items[0].sellIn).toBe(-1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { Item, GildedRose } from '../gilded-rose'
|
||||
import { GildedRose, Item } from '../gilded-rose'
|
||||
|
||||
export const itemsGoldenMaster = [
|
||||
new Item('+5 Dexterity Vest', 10, 20), //
|
||||
@ -13,13 +13,13 @@ export const itemsGoldenMaster = [
|
||||
new Item('Conjured Mana Cake', 3, 6),
|
||||
]
|
||||
|
||||
// export const gildedRose = new GildedRose(itemsGoldenMaster)
|
||||
// const days = 2
|
||||
// for (let i = 0; i < days; i++) {
|
||||
// console.log('-------- day ' + i + ' --------')
|
||||
// console.log('name, sellIn, quality')
|
||||
// itemsGoldenMaster.forEach(element => {
|
||||
// console.log(element.name + ' ' + element.sellIn + ' ' + element.quality)
|
||||
// })
|
||||
// console.log()
|
||||
// }
|
||||
export const gildedRose = new GildedRose(itemsGoldenMaster)
|
||||
const days = 2
|
||||
for (let i = 0; i < days; i++) {
|
||||
console.log('-------- day ' + i + ' --------')
|
||||
console.log('name, sellIn, quality')
|
||||
itemsGoldenMaster.forEach(element => {
|
||||
console.log(element.name + ' ' + element.sellIn + ' ' + element.quality)
|
||||
})
|
||||
console.log()
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user