mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-16 06:51:27 +00:00
Done
Updated updateQuality method to include conjured mana cake items Created updateQuality2 method to refactor the code Created tests for updateQuality and then duplicated the tests for updateQuality2
This commit is contained in:
parent
bc7de77181
commit
d4fea26156
@ -19,51 +19,142 @@ export class GildedRose {
|
|||||||
|
|
||||||
updateQuality() {
|
updateQuality() {
|
||||||
for (let i = 0; i < this.items.length; i++) {
|
for (let i = 0; i < this.items.length; i++) {
|
||||||
if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if (this.items[i].name != "Conjured Mana Cake") {
|
||||||
if (this.items[i].quality > 0) {
|
if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
if (this.items[i].quality > 0) {
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
}
|
this.items[i].quality = this.items[i].quality - 1
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
|
||||||
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if (this.items[i].sellIn < 11) {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (this.items[i].sellIn < 6) {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
this.items[i].sellIn = this.items[i].sellIn - 1;
|
|
||||||
}
|
|
||||||
if (this.items[i].sellIn < 0) {
|
|
||||||
if (this.items[i].name != 'Aged Brie') {
|
|
||||||
if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if (this.items[i].quality > 0) {
|
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.items[i].quality < 50) {
|
if (this.items[i].quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
this.items[i].quality = this.items[i].quality + 1
|
||||||
|
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
|
if (this.items[i].sellIn < 11) {
|
||||||
|
if (this.items[i].quality < 50) {
|
||||||
|
this.items[i].quality = this.items[i].quality + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.items[i].sellIn < 6) {
|
||||||
|
if (this.items[i].quality < 50) {
|
||||||
|
this.items[i].quality = this.items[i].quality + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
this.items[i].sellIn = this.items[i].sellIn - 1;
|
||||||
|
}
|
||||||
|
if (this.items[i].sellIn < 0) {
|
||||||
|
if (this.items[i].name != 'Aged Brie') {
|
||||||
|
if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
|
if (this.items[i].quality > 0) {
|
||||||
|
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
this.items[i].quality = this.items[i].quality - 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (this.items[i].quality < 50) {
|
||||||
|
this.items[i].quality = this.items[i].quality + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.items[i].sellIn--;
|
||||||
|
if(this.items[i].sellIn >= 0) {
|
||||||
|
this.items[i].quality = this.items[i].quality - 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.items[i].quality = this.items[i].quality - 4;
|
||||||
|
}
|
||||||
|
if(this.items[i].quality < 0) {
|
||||||
|
this.items[i].quality = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.items;
|
return this.items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateSellIn(i){
|
||||||
|
if(this.items[i].name != 'Sulfuras, Hand of Ragnaros')
|
||||||
|
this.items[i].sellIn--;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQualitySulfuras(i){
|
||||||
|
this.items[i].quality = 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQualityAgedBrie(i){
|
||||||
|
if(this.items[i].sellIn < 0) {
|
||||||
|
this.items[i].quality = this.items[i].quality + 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.items[i].quality = this.items[i].quality + 1;
|
||||||
|
}
|
||||||
|
this.items[i].quality = Math.min(this.items[i].quality,50)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQualityBackstage(i){
|
||||||
|
if(this.items[i].sellIn < 0) {
|
||||||
|
this.items[i].quality = 0;
|
||||||
|
}
|
||||||
|
else if(this.items[i].sellIn >= 10) {
|
||||||
|
this.items[i].quality = this.items[i].quality + 1;
|
||||||
|
}
|
||||||
|
else if(this.items[i].sellIn >= 5) {
|
||||||
|
this.items[i].quality = this.items[i].quality + 2;
|
||||||
|
}
|
||||||
|
else if(this.items[i].sellIn >= 0) {
|
||||||
|
this.items[i].quality = this.items[i].quality + 3;
|
||||||
|
}
|
||||||
|
this.items[i].quality = Math.min(this.items[i].quality,50)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQualityConjured(i){
|
||||||
|
if(this.items[i].sellIn < 0) {
|
||||||
|
this.items[i].quality = this.items[i].quality - 4;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.items[i].quality = this.items[i].quality - 2;
|
||||||
|
}
|
||||||
|
this.items[i].quality = Math.max(this.items[i].quality,0)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQualityAnythingElse(i){
|
||||||
|
if(this.items[i].sellIn < 0) {
|
||||||
|
this.items[i].quality = this.items[i].quality - 2;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.items[i].quality = this.items[i].quality - 1;
|
||||||
|
}
|
||||||
|
this.items[i].quality = Math.max(this.items[i].quality,0)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateQuality2(){
|
||||||
|
for(let i = 0; i < this.items.length; i++) {
|
||||||
|
this.updateSellIn(i);
|
||||||
|
if(this.items[i].name == 'Sulfuras, Hand of Ragnaros') {
|
||||||
|
this.updateQualitySulfuras(i)
|
||||||
|
}
|
||||||
|
else if(this.items[i].name == 'Aged Brie') {
|
||||||
|
this.updateQualityAgedBrie(i);
|
||||||
|
}
|
||||||
|
else if(this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
||||||
|
this.updateQualityBackstage(i);
|
||||||
|
}
|
||||||
|
else if(this.items[i].name == 'Conjured Mana Cake') {
|
||||||
|
this.updateQualityConjured(i);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
this.updateQualityAnythingElse(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.items
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
10280
TypeScript/package-lock.json
generated
10280
TypeScript/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -13,17 +13,21 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.18.6",
|
||||||
|
"@babel/preset-env": "^7.18.6",
|
||||||
|
"@babel/preset-typescript": "^7.18.6",
|
||||||
"@types/chai": "^4.2.22",
|
"@types/chai": "^4.2.22",
|
||||||
"@types/jest": "^27.0.2",
|
"@types/jest": "^27.0.2",
|
||||||
"@types/mocha": "^9.0.0",
|
"@types/mocha": "^9.0.0",
|
||||||
"@types/node": "^16.11.7",
|
"@types/node": "^16.11.7",
|
||||||
|
"babel-jest": "^28.1.1",
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
"jest": "^27.3.1",
|
"jest": "^27.5.1",
|
||||||
"mocha": "^9.1.3",
|
"mocha": "^9.1.3",
|
||||||
"nyc": "~15.1.0",
|
"nyc": "~15.1.0",
|
||||||
"rimraf": "~3.0.2",
|
"rimraf": "~3.0.2",
|
||||||
"source-map-support": "^0.5.20",
|
"source-map-support": "^0.5.20",
|
||||||
"ts-jest": "^27.0.7",
|
"ts-jest": "^27.1.5",
|
||||||
"ts-node": "^10.4.0",
|
"ts-node": "^10.4.0",
|
||||||
"tsconfig-paths": "^3.11.0",
|
"tsconfig-paths": "^3.11.0",
|
||||||
"typescript": "^4.4.4"
|
"typescript": "^4.4.4"
|
||||||
|
|||||||
@ -1,10 +1,882 @@
|
|||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { Item, GildedRose } from '@/gilded-rose';
|
import { Item, GildedRose } from '@/gilded-rose';
|
||||||
|
|
||||||
describe('Gilded Rose', () => {
|
describe('Gilded Rose original updateQuality', () => {
|
||||||
|
|
||||||
|
//random test:)
|
||||||
|
|
||||||
it('should foo', () => {
|
it('should foo', () => {
|
||||||
|
//given
|
||||||
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
||||||
|
//when
|
||||||
const items = gildedRose.updateQuality();
|
const items = gildedRose.updateQuality();
|
||||||
expect(items[0].name).to.equal('fixme');
|
//then
|
||||||
|
expect(items[0].name).to.equal('foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
//standard item rules
|
||||||
|
|
||||||
|
it('standard item sellin date not reached quality should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items[0].quality).to.equal(7);
|
||||||
|
});
|
||||||
|
it('standard item sellin date not reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items[0].sellIn).to.equal(3);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached quality should decrease by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items5[0].quality).to.equal(2);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items5[0].sellIn).to.equal(-1);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
const items6 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items6[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
const items6 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items6[0].sellIn).to.equal(-5);
|
||||||
|
});
|
||||||
|
it('standard item sellin date not reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('standard item sellin date not reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
//sulfuras tests
|
||||||
|
|
||||||
|
it('sulfuras item sellin date not reached quality should stay at 80', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', 2, 80)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items[0].quality).to.equal(80);
|
||||||
|
});
|
||||||
|
it('sulfuras item sellin date not reached sellin should stay at 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', 2, 80)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items[0].sellIn).to.equal(2);
|
||||||
|
});
|
||||||
|
it('sulfuras item sellin date reached quality should stay at 80', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', -4, 80)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(80);
|
||||||
|
});
|
||||||
|
it('sulfuras item sellin date reached sellin should stay at -4', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', -4, 80)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(-4);
|
||||||
|
});
|
||||||
|
|
||||||
|
//aged brie tests
|
||||||
|
|
||||||
|
it('Aged brie item sellin date not reached quality should increase by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 4, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items1[0].quality).to.equal(14);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date not reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 4, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items1[0].sellIn).to.equal(3);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached quality should increase by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(18);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(-2);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached, quality reached 50, quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached, quality reached 50, sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(-2);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date not reached, quality reached 50, quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 5, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date not reached, quality reached 50, sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 5, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
//backstage passes tests
|
||||||
|
|
||||||
|
it('Backstage pass item sellin date reached quality should go to 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(-1);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date > 10 quality should increase by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 12, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(15);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date > 10 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 12, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(10);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 quality should increase by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(17);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(5);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >= 0 quality should increase by 3', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(19);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >=0 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Backstage pass item sellin date > 10 and quality reaches 50 quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 15, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date > 10 and quality reaches 50 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 15, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(13);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 and quality reaches 50 quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 and quality reaches 50 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(5);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >= 0 and quality reaches 50 quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >=0 and quality reaches 50 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
//conjured items
|
||||||
|
|
||||||
|
it('conjured item sellin date not reached quality should decrease by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items[0].quality).to.equal(6);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date not reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items[0].sellIn).to.equal(3);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached quality should decrease by 4', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 14)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items5[0].quality).to.equal(2);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 14)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items5[0].sellIn).to.equal(-1);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
const items6 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items6[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
const items4 = gildedRose.updateQuality();
|
||||||
|
const items5 = gildedRose.updateQuality();
|
||||||
|
const items6 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items6[0].sellIn).to.equal(-5);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date not reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date not reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality();
|
||||||
|
const items2 = gildedRose.updateQuality();
|
||||||
|
const items3 = gildedRose.updateQuality();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(2);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Gilded Rose new updateQuality2', () => {
|
||||||
|
|
||||||
|
//random test:)
|
||||||
|
|
||||||
|
it('should foo', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items[0].name).to.equal('foo');
|
||||||
|
});
|
||||||
|
|
||||||
|
//standard item rules
|
||||||
|
|
||||||
|
it('standard item sellin date not reached quality should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items[0].quality).to.equal(7);
|
||||||
|
});
|
||||||
|
it('standard item sellin date not reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items[0].sellIn).to.equal(3);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached quality should decrease by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items5[0].quality).to.equal(2);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items5[0].sellIn).to.equal(-1);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
const items6 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items6[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('standard item sellin date reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
const items6 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items6[0].sellIn).to.equal(-5);
|
||||||
|
});
|
||||||
|
it('standard item sellin date not reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('standard item sellin date not reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('ceva', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
//sulfuras tests
|
||||||
|
|
||||||
|
it('sulfuras item sellin date not reached quality should stay at 80', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', 2, 80)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items[0].quality).to.equal(80);
|
||||||
|
});
|
||||||
|
it('sulfuras item sellin date not reached sellin should stay at 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', 2, 80)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items[0].sellIn).to.equal(2);
|
||||||
|
});
|
||||||
|
it('sulfuras item sellin date reached quality should stay at 80', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', -4, 80)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(80);
|
||||||
|
});
|
||||||
|
it('sulfuras item sellin date reached sellin should stay at -4', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Sulfuras, Hand of Ragnaros', -4, 80)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(-4);
|
||||||
|
});
|
||||||
|
|
||||||
|
//aged brie tests
|
||||||
|
|
||||||
|
it('Aged brie item sellin date not reached quality should increase by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 4, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items1[0].quality).to.equal(14);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date not reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 4, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items1[0].sellIn).to.equal(3);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached quality should increase by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(18);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(-2);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached, quality reached 50, quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date reached, quality reached 50, sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(-2);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date not reached, quality reached 50, quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 5, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Aged brie item sellin date not reached, quality reached 50, sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Aged Brie', 5, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
//backstage passes tests
|
||||||
|
|
||||||
|
it('Backstage pass item sellin date reached quality should go to 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 1, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(-1);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date > 10 quality should increase by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 12, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(15);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date > 10 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 12, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(10);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 quality should increase by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(17);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(5);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >= 0 quality should increase by 3', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(19);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >=0 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 13)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Backstage pass item sellin date > 10 and quality reaches 50 quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 15, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Backstage pass item sellin date > 10 and quality reaches 50 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 15, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(13);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 and quality reaches 50 quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 10 >= sellin date > 5 and quality reaches 50 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 7, 49)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(5);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >= 0 and quality reaches 50 quality should stay at 50', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].quality).to.equal(50);
|
||||||
|
});
|
||||||
|
it('Backstage pass item 5 >= sellin date >=0 and quality reaches 50 sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 2, 48)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items2[0].sellIn).to.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
//conjured items
|
||||||
|
|
||||||
|
it('conjured item sellin date not reached quality should decrease by 2', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items[0].quality).to.equal(6);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date not reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 8)]);
|
||||||
|
//when
|
||||||
|
const items = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items[0].sellIn).to.equal(3);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached quality should decrease by 4', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 14)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items5[0].quality).to.equal(2);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 4, 14)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items5[0].sellIn).to.equal(-1);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
const items6 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items6[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 1, 8)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
const items4 = gildedRose.updateQuality2();
|
||||||
|
const items5 = gildedRose.updateQuality2();
|
||||||
|
const items6 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items6[0].sellIn).to.equal(-5);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date not reached 0 quality reached quality should stay at 0', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].quality).to.equal(0);
|
||||||
|
});
|
||||||
|
it('conjured item sellin date not reached 0 quality reached sellin should decrease by 1', () => {
|
||||||
|
//given
|
||||||
|
const gildedRose = new GildedRose([new Item('Conjured Mana Cake', 5, 1)]);
|
||||||
|
//when
|
||||||
|
const items1 = gildedRose.updateQuality2();
|
||||||
|
const items2 = gildedRose.updateQuality2();
|
||||||
|
const items3 = gildedRose.updateQuality2();
|
||||||
|
//then
|
||||||
|
expect(items3[0].sellIn).to.equal(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user