Add conjured items

This commit is contained in:
Dan Holmes 2020-12-04 09:10:18 +00:00
parent 9234534172
commit fa105c7c35
2 changed files with 26 additions and 0 deletions

View File

@ -99,5 +99,23 @@ describe('Shop', () => {
expect(items[0].quality).toEqual(0);
});
});
describe('Conjured', () => {
beforeEach(() => {
item.name = 'Conjured pickle';
});
it('will decrease the quality by 2 before sell by', () => {
item.sellIn = 5;
item.quality = 5;
const items = gildedRose.updateQuality();
expect(items[0].quality).toEqual(5 - 2);
});
it('will decrease the quality by 4 after sell by', () => {
item.sellIn = 0;
item.quality = 5;
const items = gildedRose.updateQuality();
expect(items[0].quality).toEqual(5 - 4);
});
});
});
});

View File

@ -0,0 +1,8 @@
exports.regex_matcher = /conjured/;
exports.qualityChange = function (sellIn, quality) {
if (sellIn <= 0) {
return -4;
} else {
return -2;
}
};