Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

my solution for the task #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -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

9 changes: 8 additions & 1 deletion app/gilded-rose.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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') {
Expand All @@ -66,4 +73,4 @@ export class GildedRose {

return this.items;
}
}
}
15 changes: 13 additions & 2 deletions test/jest/gilded-rose.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
})
});