From ab27f76db7a5d36e50444a995ef239eb8989f4c2 Mon Sep 17 00:00:00 2001 From: Ben Hemann Date: Mon, 7 Jun 2021 13:06:45 -0500 Subject: [PATCH] completed testing for specific items --- TypeScript/test/gilded-rose.spec.ts | 95 +++++++++++++++++++++++++++-- 1 file changed, 90 insertions(+), 5 deletions(-) diff --git a/TypeScript/test/gilded-rose.spec.ts b/TypeScript/test/gilded-rose.spec.ts index 6b42e57e..7008473a 100644 --- a/TypeScript/test/gilded-rose.spec.ts +++ b/TypeScript/test/gilded-rose.spec.ts @@ -17,9 +17,7 @@ describe('Gilded Rose', function () { it('Should give back updated SellIn', function () { const gildedRose = new GildedRose([ new Item('foo', 5, 5)]); const items = gildedRose.updateQuality(); - expect(items[0].sellIn).to.equal(4); - expect(items[0].quality).to.equal(4); }); }); @@ -31,8 +29,23 @@ describe('Gilded Rose', function () { }); }); -// tests to check if specific items work correctly +describe('Gilded Rose', function () { + it('Quality should go down twice as much after sellIn date passes', function () { + const gildedRose = new GildedRose([ new Item('foo', -1, 5)]); + const items = gildedRose.updateQuality(); + expect(items[0].quality).to.equal(3); + }); +}); +describe('Gilded Rose', function () { + it('Quality should not go negative', function () { + const gildedRose = new GildedRose([ new Item('foo', -1, 0)]); + const items = gildedRose.updateQuality(); + expect(items[0].quality).to.equal(0); + }); +}); + +// tests for backstage passes describe('Backstage Pass', function () { it('Backstage pass should increase in quality by 2 with only 10 days left', function () { const gildedRose = new GildedRose ([ new Item('Backstage passes to a TAFKAL80ETC concert', 10, 5)]); @@ -49,7 +62,6 @@ describe('Backstage Pass', function () { }) }) - describe('Backstage Pass', function () { it('Backstage pass should increase in quality by 3, but quality is at 49', function () { const gildedRose = new GildedRose ([ new Item('Backstage passes to a TAFKAL80ETC concert', 4, 49)]); @@ -64,4 +76,77 @@ describe('Backstage Pass', function () { const items = gildedRose.updateQuality(); expect(items[0].quality).to.equal(0); }) -}) \ No newline at end of file +}) + +// tests for aged brie +describe('Gilded Rose', () => { + + describe('Aged Brie Tests', () => { + var gildedRose: GildedRose; + + beforeEach(() => { + gildedRose = new GildedRose([new Item('Aged Brie', 7, 11)]); + }); + + it('Aged Brie should be added to item array', () => { + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.name).to.equal('Aged Brie'); + }); + + it('should give back updated sellIn ', () => { + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.sellIn).to.equal(6); + }); + + it('should give back updated quality, Aged Brie increases in quality as days go on', () => { + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.quality).to.equal(12); + }); + + it('Aged Brie quality caps at 50', () => { + gildedRose.items[0].quality = 50; + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.quality).to.equal(50); + }); + + it('Aged Brie quality continues to go up even after sellIn date passes', () => { + gildedRose.items[0].sellIn = -12; + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.quality).to.equal(13); + }); + }); +}); + +// tests for hand of ragnaros +describe('Gilded Rose', () => { + + describe('Sulfuras, Hand of Ragnaros Tests', () => { + var gildedRose: GildedRose; + + beforeEach(() => { + gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', 1, 80)]); + }); + + it('Sulfuras, Hand of Ragnaros should be added to item array', () => { + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.name).to.equal('Sulfuras, Hand of Ragnaros'); + }); + + it('Sulfuras, Hand of Ragnaros, should not have an updated sellIn ', () => { + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.sellIn).to.equal(1); + }); + + it('Sulfuras, Hand of Ragnaros quality should not change', () => { + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.quality).to.equal(80); + }); + + it('Sulfuras, Hand of Ragnaros should not have degraded quality even after sellIn date passes', () => { + gildedRose.items[0].sellIn = -10; + const actualUpdatedItem = gildedRose.updateQuality()[0]; + expect(actualUpdatedItem.quality).to.equal(80); + }); + }); +}); +