GildedRose-Refactoring-Kata/TypeScript
2025-07-24 16:44:45 +02:00
..
app Added new functionality to support conjured items 2025-07-24 16:08:14 +02:00
snapshot-tests Added new functionality to support conjured items 2025-07-24 16:08:14 +02:00
.editorconfig Add Jest to TypeScript (and update dependencies) 2021-11-09 18:41:26 +01:00
.gitignore Do not commit the lock file. 2023-11-29 12:13:35 +01:00
jest.config.ts Refactor tests 2025-07-24 12:56:19 +02:00
package.json Refactor tests 2025-07-24 12:56:19 +02:00
README.md Updated readme.md file to include some extra explanations 2025-07-24 16:44:45 +02:00
tsconfig.json Introduce improved file structure, move update logic to legacyBehavior class 2025-07-24 11:49:26 +02:00

Gilded Rose

This is the Gilded Rose kata in TypeScript.

Architecture

The update logic is encapsulated in behaviors that define how different types of items are updated.

  • The Item class represents an item with properties like name, sellIn, and quality.

  • The IUpdateBehavior interface defines the contract for item update behaviors. Which is basically an update method that takes an Item and returns an updated Item. Each specific item type has its own implementation of this interface, such as AgedBrieBehavior, BackstagePassBehavior, etc. You can find these implementations in the app/update-behaviors/implementations directory.

  • The getUpdateBehaviorFor(item) function checks the item name and returns the correct instantiated behavior class. This is done in the app/update-behaviors/behavior-resolver.ts file.

  • The GildedRose class is responsible for managing the items. It has an updateQuality method that iterates through the items, retrieves the appropriate update behavior for each item via the resolver, and calls its update method.

Getting started

Install dependencies

npm install

Run the unit tests from the Command-Line

I chose to use Jest for unit tests and snapshot tests.

npm run test

To run all tests in watch mode

npm run test:watch