additional first iteration tests

This commit is contained in:
James Hall 2023-01-04 20:44:54 -06:00
parent e2dfb3376e
commit 70df85f98d

View File

@ -2,44 +2,56 @@ const {Shop, Item} = require("../src/gilded_rose");
const gildedRose = new Shop([ const gildedRose = new Shop([
new Item("+5 Dexterity Vest", 10, 20), new Item("+5 Dexterity Vest", 10, 20),
new Item("Aged Brie", 2, 0), new Item("Aged Brie", 2, 0),
new Item("Elixir of the Mongoose", 5, 7),
new Item("Sulfuras, Hand of Ragnaros", 0, 80), new Item("Sulfuras, Hand of Ragnaros", 0, 80),
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20), 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", 10, 49),
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), // new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
// This Conjured item does not work properly yet // This Conjured item does not work properly yet
new Item("Conjured Mana Cake", 3, 6), // new Item("Conjured Mana Cake", 3, 6),
]); ]);
describe("Initial state", function () { describe("Initial state", function () {
it("number of items should equal 9", function () { it("number of items should equal 4", function () {
expect(gildedRose.items.length).toBe(9); expect(gildedRose.items.length).toBe(4);
}); });
}); });
describe("After one updateQuality call", function() { describe("After one updateQuality call", function() {
const items = gildedRose.updateQuality();
it("Miscellaneous item should have decremented sellIn by 1", function() { it("Miscellaneous item should have decremented sellIn by 1", function() {
const items = gildedRose.updateQuality();
expect(items[0].sellIn).toBe(9); expect(items[0].sellIn).toBe(9);
}); });
it("Miscellaneous item should have decremented quality by 1", function() { it("Miscellaneous item should have decremented quality by 1", function() {
const items = gildedRose.updateQuality();
expect(items[0].quality).toBe(19); expect(items[0].quality).toBe(19);
}); });
it("Aged Brie should have decremented sellIn by 1", function() { it("Aged Brie should have decremented sellIn by 1", function() {
const items = gildedRose.updateQuality();
expect(items[1].sellIn).toBe(1); expect(items[1].sellIn).toBe(1);
}); });
it("Aged Brie should have incremented quality by 1", function() { it("Aged Brie should have incremented quality by 1", function() {
const items = gildedRose.updateQuality();
expect(items[1].quality).toBe(1); expect(items[1].quality).toBe(1);
}); });
it("Sulfuras 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("Backstage passes should have decremented sellIn by 1", function () {
expect(items[3].sellIn).toBe(14);
});
it("Backstage passes should have incremented quality by 1", function () {
expect(items[3].quality).toBe(21);
});
// it("should foo", function() { // it("should foo", function() {
// const items = gildedRose.updateQuality(); // const items = gildedRose.updateQuality();
// expect(items[0].name).toBe("fixme"); // expect(items[0].name).toBe("fixme");