Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Item, GildedRose } from "@/gilded-rose";
- describe("Gilded Rose", () => {
- it("quality should decrease by 1 if sellIn not expire", () => {
- const gildedRose = new GildedRose([new Item("foo", 2, 10)]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(new Item("foo", 1, 9));
- });
- it("quality double decrese when expired", () => {
- const gildedRose = new GildedRose([new Item("foo", 0, 10)]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(new Item("foo", -1, 8));
- });
- it("quality Sulfuras, Hand of Ragnaros should not decrease when updateQuality", () => {
- const gildedRose = new GildedRose([
- new Item("Sulfuras, Hand of Ragnaros", 2, 10),
- ]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(
- new Item("Sulfuras, Hand of Ragnaros", 2, 10),
- );
- });
- it("quality of Aged Brie should increase when updateQuality", () => {
- const gildedRose = new GildedRose([new Item("Aged Brie", 2, 10)]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(new Item("Aged Brie", 1, 11));
- });
- it("quality of Aged Brie can not be more than 50", () => {
- const gildedRose = new GildedRose([new Item("Aged Brie", 2, 50)]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(new Item("Aged Brie", 1, 50));
- });
- it("quality of Aged Brie can not increase more than 50", () => {
- const gildedRose = new GildedRose([new Item("Aged Brie", -1, 46)]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(new Item("Aged Brie", -2, 48));
- });
- it("quality of Backstage can not be more than 50", () => {
- const gildedRose = new GildedRose([
- new Item("Backstage passes to a TAFKAL80ETC concert", 2, 50),
- ]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(
- new Item("Backstage passes to a TAFKAL80ETC concert", 1, 50),
- );
- });
- it("Backstage's sellIn more than 10 should increase by 1", () => {
- const gildedRose = new GildedRose([
- new Item("Backstage passes to a TAFKAL80ETC concert", 12, 10),
- ]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(
- new Item("Backstage passes to a TAFKAL80ETC concert", 11, 11),
- );
- });
- it("Backstage's sellIn less than 10 should increase by 2", () => {
- const gildedRose = new GildedRose([
- new Item("Backstage passes to a TAFKAL80ETC concert", 10, 10),
- ]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(
- new Item("Backstage passes to a TAFKAL80ETC concert", 9, 12),
- );
- });
- it("Backstage's sellIn less than 5 should increase by 3", () => {
- const gildedRose = new GildedRose([
- new Item("Backstage passes to a TAFKAL80ETC concert", 5, 10),
- ]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(
- new Item("Backstage passes to a TAFKAL80ETC concert", 4, 13),
- );
- });
- it("Backstage's sellIn expire, quality should be 0", () => {
- const gildedRose = new GildedRose([
- new Item("Backstage passes to a TAFKAL80ETC concert", 0, 10),
- ]);
- const items = gildedRose.updateQuality();
- expect(items[0]).toStrictEqual(
- new Item("Backstage passes to a TAFKAL80ETC concert", -1, 0),
- );
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement