Writing test case for genaric items without logic. - Test driven development

This commit is contained in:
Pabasara Jayawardhana 2021-09-19 06:16:27 +05:30
parent 74291a62a6
commit dfda89c474
2 changed files with 22 additions and 3 deletions

View File

@ -6,6 +6,16 @@ class Item {
}
}
class ItemUpdater {
constructor(item) {
this.item = item;
}
updateQuality() {
return this.item;
}
}
class Shop {
constructor(items=[]){
this.items = items;
@ -63,5 +73,6 @@ class Shop {
module.exports = {
Item,
Shop
Shop,
ItemUpdater
}

View File

@ -1,9 +1,17 @@
const {Shop, Item} = require("../src/gilded_rose");
const {Shop, Item, ItemUpdater} = require("../src/gilded_rose");
describe("Gilded Rose", function() {
it("should foo", function() {
const gildedRose = new Shop([new Item("foo", 0, 0)]);
const items = gildedRose.updateQuality();
expect(items[0].name).toBe("fixme");
expect(items[0].name).toBe("foo");
});
});
describe("Gilded Rose check common rules", function () {
it("should foo", function () {
const gildedRose = new ItemUpdater(new Item("Aged Brie", 10, 0));
const item = gildedRose.updateQuality();
expect(item.quality).toBe(10);
});
});