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

Tests done, refactoring to be done. #19

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
6 changes: 4 additions & 2 deletions app/gilded-rose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class GildedRose {
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
Expand All @@ -50,18 +51,19 @@ export class GildedRose {
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
this.items[i].quality -= 1
}
}
} else {
this.items[i].quality = this.items[i].quality - this.items[i].quality
this.items[i].quality = 0
}
} else {
if (this.items[i].quality < 50) {
this.items[i].quality = this.items[i].quality + 1
}
}
}

}

return this.items;
Expand Down
100 changes: 61 additions & 39 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"rimraf": "~3.0.2",
"source-map-support": "^0.5.20",
"ts-jest": "^27.0.7",
"ts-node": "^10.4.0",
"ts-node": "^10.9.2",
"tsconfig-paths": "^3.11.0",
"typescript": "^4.4.4"
"typescript": "^4.9.5"
}
}
88 changes: 86 additions & 2 deletions test/jest/gilded-rose.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Gilded Rose', () => {
const items = gildedRose.updateQuality();

// Assert
expect(items[0].name).toBe('bar');
expect(items[0].name).toBe('foo');
});

it('sword quality drops by 1', () => {
Expand All @@ -20,6 +20,90 @@ describe('Gilded Rose', () => {
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(1);
expect(items[0].quality).toBe(0);
})

it('Brie', () => {
// Arrange
const gildedRose = new GildedRose([new Item('Brie', 1, 1)]);

// Act
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(0);

})

it('Brie quality', () => {
// Arrange
const gildedRose = new GildedRose([new Item('Aged Brie', 1, 49)]);

// Act
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(50);

})

it('TAFKAL80ETC', () => {
// Arrange
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 10, 49)]);

// Act
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(50);

})

it('TAFKAL80ETC2', () => {
// Arrange
const gildedRose = new GildedRose([new Item('Aged Brie', 5, 51)]);

// Act
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(51);

})

it('TAFKAL80ETC3', () => {
// Arrange
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', 5, 48)]);

// Act
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(50);

})

it('testx', () => {
// Arrange
const gildedRose = new GildedRose([new Item('Backstage passes to a TAFKAL80ETC concert', -10, 100)]);

// Act
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(0);

})

it('testy', () => {
// Arrange
const gildedRose = new GildedRose([new Item('Elixir of the Mongoose', -1, 10)]);

// Act
const items = gildedRose.updateQuality();

// Assert
expect(items[0].quality).toBe(8);

})
});