mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
categorize tests and add new ones
This commit is contained in:
parent
28ed899f66
commit
ebf0a6005f
@ -1,25 +1,22 @@
|
||||
const {Shop, Item} = require("../src/gilded_rose");
|
||||
|
||||
const gildedRose = new Shop([
|
||||
new Item("+5 Dexterity Vest", 10, 20),
|
||||
new Item("Aged Brie", 2, 0),
|
||||
new Item("Sulfuras, Hand of Ragnaros", 0, 80),
|
||||
new Item("Sulfuras, Hand of Ragnaros", 0, 35),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
|
||||
|
||||
// This Conjured item does not work properly yet
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 45),
|
||||
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 32),
|
||||
new Item("Conjured Mana Cake", 3, 6),
|
||||
new Item("Expired Pears", -1, 11),
|
||||
new Item("Overpriced Trinket", 10, 55),
|
||||
new Item("Conjured Mana Cake", -3, 6),
|
||||
]);
|
||||
|
||||
describe("Initial state", function () {
|
||||
it("number of items should equal 8", function () {
|
||||
expect(gildedRose.items.length).toBe(8);
|
||||
});
|
||||
});
|
||||
const items = gildedRose.updateQuality();
|
||||
|
||||
describe("After one updateQuality call", function() {
|
||||
const items = gildedRose.updateQuality();
|
||||
|
||||
|
||||
it("Miscellaneous item should have decremented sellIn by 1", function() {
|
||||
expect(items[0].sellIn).toBe(9);
|
||||
});
|
||||
@ -28,22 +25,37 @@ describe("After one updateQuality call", function() {
|
||||
expect(items[0].quality).toBe(19);
|
||||
});
|
||||
|
||||
it("Aged Brie should have decremented sellIn by 1", function() {
|
||||
it("Expired item should have decremented quality by 2", function () {
|
||||
expect(items[7].quality).toBe(9);
|
||||
});
|
||||
|
||||
it("Overpriced item should have reset quality to 50", function () {
|
||||
expect(items[8].quality).toBe(50);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("After one updateQuality call, Aged Brie", function () {
|
||||
it("should have decremented sellIn by 1", function () {
|
||||
expect(items[1].sellIn).toBe(1);
|
||||
});
|
||||
|
||||
it("Aged Brie should have incremented quality by 1", function() {
|
||||
it("should have incremented quality by 1", function () {
|
||||
expect(items[1].quality).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
it("Sulfuras should have same sellIn", function () {
|
||||
describe("After one updateQuality call, Sulfuras", function () {
|
||||
it("should have same sellIn", function () {
|
||||
expect(items[2].sellIn).toBe(0);
|
||||
});
|
||||
|
||||
it("Sulfuras should have same quality", function () {
|
||||
expect(items[2].quality).toBe(80);
|
||||
it("should have same quality", function () {
|
||||
expect(items[2].quality).toBe(35);
|
||||
});
|
||||
});
|
||||
|
||||
describe("After one updateQuality call", function () {
|
||||
it("First backstage pass should have decremented sellIn by 1", function () {
|
||||
expect(items[3].sellIn).toBe(14);
|
||||
});
|
||||
@ -57,7 +69,7 @@ describe("After one updateQuality call", function() {
|
||||
});
|
||||
|
||||
it("Second backstage pass should have incremented quality by 2", function () {
|
||||
expect(items[4].quality).toBe(51);
|
||||
expect(items[4].quality).toBe(47);
|
||||
});
|
||||
|
||||
it("Third backstage pass should have decremented sellIn by 1", function () {
|
||||
@ -65,17 +77,20 @@ describe("After one updateQuality call", function() {
|
||||
});
|
||||
|
||||
it("Third backstage pass should have incremented quality by 3", function () {
|
||||
expect(items[5].quality).toBe(52);
|
||||
expect(items[5].quality).toBe(35);
|
||||
});
|
||||
|
||||
it("Conjured item should have decremented sellIn by 1", function () {
|
||||
expect(items[5].sellIn).toBe(2);
|
||||
});
|
||||
|
||||
it("Conjured item pass should have decremented quality by 2", function () {
|
||||
expect(items[5].quality).toBe(4);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("After one updateQuality call, Conjured item", function () {
|
||||
it("should have decremented sellIn by 1", function () {
|
||||
expect(items[6].sellIn).toBe(2);
|
||||
});
|
||||
|
||||
it("should have decremented quality by 2", function () {
|
||||
expect(items[6].quality).toBe(4);
|
||||
});
|
||||
|
||||
it("should have decremented quality by 4 if expired", function () {
|
||||
expect(items[9].quality).toBe(2);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user