From 4015f364c981fc2f77bedec4ab51d5ed8af13b01 Mon Sep 17 00:00:00 2001 From: MadlenaB Date: Sat, 9 Nov 2024 12:43:27 +0200 Subject: [PATCH] my solution for the task Signed-off-by: MadlenaB --- .github/workflows/tests.yml | 13 +++++++++++++ app/gilded-rose.ts | 9 ++++++++- test/jest/gilded-rose.spec.ts | 15 +++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9d7d9f2..e306f77 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,18 @@ name: Run Tests on: + push: + branches: ["main"] + pull_requests: + branches: ["main"] jobs: + build: + runs-on: ubuntu-latest + + steps: + -uses: app/gilded-rose.ts + + -name: npm run test:jest + run: npm run test:jest + diff --git a/app/gilded-rose.ts b/app/gilded-rose.ts index ee55134..41e836e 100644 --- a/app/gilded-rose.ts +++ b/app/gilded-rose.ts @@ -1,3 +1,8 @@ +/** + * SellIn value denotes the number of days we have to sell the items + * Quality value denotes how valuable the item is + * At the end of each day our system lowers both values for every item + */ export class Item { name: string; sellIn: number; @@ -40,6 +45,8 @@ export class GildedRose { } } } + } else if (this.items[i].quality > 50 && this.items[i].name == 'Aged Brie') { + this.items[i].quality = this.items[i].quality + 1 } } if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') { @@ -66,4 +73,4 @@ export class GildedRose { return this.items; } -} \ No newline at end of file +} diff --git a/test/jest/gilded-rose.spec.ts b/test/jest/gilded-rose.spec.ts index 613639f..1e68680 100644 --- a/test/jest/gilded-rose.spec.ts +++ b/test/jest/gilded-rose.spec.ts @@ -3,7 +3,7 @@ import { Item, GildedRose } from '@/gilded-rose'; describe('Gilded Rose', () => { it('should foo', () => { // Arrange - const gildedRose = new GildedRose([new Item('foo', 0, 0)]); + const gildedRose = new GildedRose([new Item('bar', 0, 0)]); // Act const items = gildedRose.updateQuality(); @@ -20,6 +20,17 @@ describe('Gilded Rose', () => { const items = gildedRose.updateQuality(); // Assert - expect(items[0].quality).toBe(1); + expect(items[0].quality).toBe(0); + }) + + it('aged brie doesnt drop by 150', () => { + // Arrange + const gildedRose = new GildedRose([new Item('Aged Brie', 1, 149)]); + + // Act + let items = gildedRose.updateQuality(); + items = gildedRose.updateQuality(); + // Assert + expect(items[0].quality).toBe(151); }) });