Last active
April 3, 2025 18:37
-
-
Save trikitrok/44d7395be58754ed537bbb1dd2bb6eef to your computer and use it in GitHub Desktop.
legacy argent rose code including Lanzarote Wine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class ArgentRoseStore | |
// ... | |
private updateQuality(product: Product): void { | |
if (product.isTheatrePasses()) { | |
if (product.sellIn < 0) { | |
product.dropQualityToMinimum(); | |
} else if (product.sellIn < 5) { | |
product.increaseQualityBy(3); | |
} else { | |
product.increaseQualityBy(1); | |
} | |
} else if (product.isLanzaroteWine()) { | |
product.increaseQualityBy(2); | |
} else { | |
product.decreaseQualityBy(2); | |
} | |
} | |
/// .... | |
} | |
export class Product { | |
/// ... | |
isLanzaroteWine() { | |
return this.description === "Lanzarote Wine"; | |
} | |
/// ... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it("Lanzarote Wine increases quality by one", async () => { | |
const store = storeIncluding(lanzaroteWine(3, 10)); | |
await store.update(); | |
expect(store.getSavedInventory()).toEqual(inventoryIncluding(lanzaroteWine(2, 12))); | |
}); | |
it("Expired Lanzarote Wine increases quality twice as fast", async () => { | |
const store = storeIncluding(lanzaroteWine(-5, 10)); | |
await store.update(); | |
expect(store.getSavedInventory()).toEqual(inventoryIncluding(lanzaroteWine(-6, 14))); | |
}); | |
function lanzaroteWine(sellIn: number, quality: number): Product { | |
return new Product("Lanzarote Wine", sellIn, quality); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment