Advertisement
LynchzDEV

gilded-rose.spec.ts

Nov 17th, 2024 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TypeScript 3.42 KB | Source Code | 0 0
  1. import { Item, GildedRose } from "@/gilded-rose";
  2.  
  3. describe("Gilded Rose", () => {
  4.   it("quality should decrease by 1 if sellIn not expire", () => {
  5.     const gildedRose = new GildedRose([new Item("foo", 2, 10)]);
  6.     const items = gildedRose.updateQuality();
  7.     expect(items[0]).toStrictEqual(new Item("foo", 1, 9));
  8.   });
  9.  
  10.   it("quality double decrese when expired", () => {
  11.     const gildedRose = new GildedRose([new Item("foo", 0, 10)]);
  12.     const items = gildedRose.updateQuality();
  13.     expect(items[0]).toStrictEqual(new Item("foo", -1, 8));
  14.   });
  15.  
  16.   it("quality Sulfuras, Hand of Ragnaros should not decrease when updateQuality", () => {
  17.     const gildedRose = new GildedRose([
  18.       new Item("Sulfuras, Hand of Ragnaros", 2, 10),
  19.     ]);
  20.     const items = gildedRose.updateQuality();
  21.     expect(items[0]).toStrictEqual(
  22.       new Item("Sulfuras, Hand of Ragnaros", 2, 10),
  23.     );
  24.   });
  25.  
  26.   it("quality of Aged Brie should increase when updateQuality", () => {
  27.     const gildedRose = new GildedRose([new Item("Aged Brie", 2, 10)]);
  28.     const items = gildedRose.updateQuality();
  29.     expect(items[0]).toStrictEqual(new Item("Aged Brie", 1, 11));
  30.   });
  31.  
  32.   it("quality of Aged Brie can not be more than 50", () => {
  33.     const gildedRose = new GildedRose([new Item("Aged Brie", 2, 50)]);
  34.     const items = gildedRose.updateQuality();
  35.     expect(items[0]).toStrictEqual(new Item("Aged Brie", 1, 50));
  36.   });
  37.  
  38.   it("quality of Aged Brie can not increase more than 50", () => {
  39.     const gildedRose = new GildedRose([new Item("Aged Brie", -1, 46)]);
  40.     const items = gildedRose.updateQuality();
  41.     expect(items[0]).toStrictEqual(new Item("Aged Brie", -2, 48));
  42.   });
  43.  
  44.   it("quality of Backstage can not be more than 50", () => {
  45.     const gildedRose = new GildedRose([
  46.       new Item("Backstage passes to a TAFKAL80ETC concert", 2, 50),
  47.     ]);
  48.     const items = gildedRose.updateQuality();
  49.     expect(items[0]).toStrictEqual(
  50.       new Item("Backstage passes to a TAFKAL80ETC concert", 1, 50),
  51.     );
  52.   });
  53.  
  54.   it("Backstage's sellIn more than 10 should increase by 1", () => {
  55.     const gildedRose = new GildedRose([
  56.       new Item("Backstage passes to a TAFKAL80ETC concert", 12, 10),
  57.     ]);
  58.     const items = gildedRose.updateQuality();
  59.     expect(items[0]).toStrictEqual(
  60.       new Item("Backstage passes to a TAFKAL80ETC concert", 11, 11),
  61.     );
  62.   });
  63.  
  64.   it("Backstage's sellIn less than 10 should increase by 2", () => {
  65.     const gildedRose = new GildedRose([
  66.       new Item("Backstage passes to a TAFKAL80ETC concert", 10, 10),
  67.     ]);
  68.     const items = gildedRose.updateQuality();
  69.     expect(items[0]).toStrictEqual(
  70.       new Item("Backstage passes to a TAFKAL80ETC concert", 9, 12),
  71.     );
  72.   });
  73.  
  74.   it("Backstage's sellIn less than 5 should increase by 3", () => {
  75.     const gildedRose = new GildedRose([
  76.       new Item("Backstage passes to a TAFKAL80ETC concert", 5, 10),
  77.     ]);
  78.     const items = gildedRose.updateQuality();
  79.     expect(items[0]).toStrictEqual(
  80.       new Item("Backstage passes to a TAFKAL80ETC concert", 4, 13),
  81.     );
  82.   });
  83.  
  84.   it("Backstage's sellIn expire, quality should be 0", () => {
  85.     const gildedRose = new GildedRose([
  86.       new Item("Backstage passes to a TAFKAL80ETC concert", 0, 10),
  87.     ]);
  88.     const items = gildedRose.updateQuality();
  89.     expect(items[0]).toStrictEqual(
  90.       new Item("Backstage passes to a TAFKAL80ETC concert", -1, 0),
  91.     );
  92.   });
  93. });
  94.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement