This is my attempt at the Gilded Rose Refactoring kata (by Emily Bache) in TypeScript.
Install dependencies
npm installUses vitest for unit tests.
npm run testTo run all tests in watch mode
npm run test:watchYou may need to install ts-node
npx ts-node test/golden-master-text-test.tsOr with number of days as args:
npx ts-node test/golden-master-text-test.ts 10- Initital repo setup
- Added test cases as per requirements of the kata, that already pass because the function works expected
- Refactors begin:
- More idiomatic type definitions
- This line (57 during this commit) basically means 0
- Reduced nesting by one level by using the
exceptionalItemsarray to check if the item is exception case - Reduced nesting by one level by using the
Math.minfunction to ensure the quality is not greater than 50 - Using a
for...ofloop for cleaner, more readable code - Converted the logic to a switch case for better readability
- Added failing test case for Conjured items