mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
completed testing for specific items
This commit is contained in:
parent
20b98dac0e
commit
ab27f76db7
@ -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);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// 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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user