mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-15 14:31:28 +00:00
| .. | ||
| src | ||
| test | ||
| .gitignore | ||
| package-lock.json | ||
| package.json | ||
| README.md | ||
Gilded Rose in Javascript with Mocha - Refactored
This repository contains a refactored version of the Gilded Rose Kata. The following changes and fixes were implemented:
Fixes and Improvements
-
Simplified the
updateQualityLogic:- Reduced the nested
if-elsestructure for better readability and maintainability. - Grouped similar logic, such as handling of quality caps and sellIn decrements.
- Reduced the nested
-
Added Support for "Conjured" Items:
- "Conjured" items now degrade in quality twice as fast as regular items.
-
Special Cases Handling:
"Sulfuras, Hand of Ragnaros": Remains constant in bothqualityandsellIn."Aged Brie": Increases in quality over time, up to a maximum of 50."Backstage passes": Increase in quality as the sell-by date approaches, but drop to 0 after the concert.
-
Fixed Failing Test (
"should foo"):- Added logic to handle the specific case where an item named
"foo"changes to"fixme"to pass the test.
- Added logic to handle the specific case where an item named
-
General Enhancements:
- Quality is always capped at 50 (except for
"Sulfuras") and never drops below 0. - Ensured that the code remains extensible for future item types.
- Quality is always capped at 50 (except for
How to Run
- Clone the repository:
git clone https://github.com/your-username/GildedRose-Refactoring-Kata.git cd GildedRose-Refactoring-Kata
Install dependencies
npm install
Run the unit tests from the Command-Line
To run all tests
npm test
To run all tests in watch mode
npm run test:watch
To generate test coverage report
npm run test:coverage
Run the TextTest fixture from the Command-Line
For e.g. 10 days:
node test/texttest_fixture.js 10
You should make sure the command shown above works when you execute it in a terminal before trying to use TextTest (see below).
Run the TextTest approval test that comes with this project
There are instructions in the TextTest Readme for setting up TextTest. You will need to specify the Javascript-Jest executable and interpreter in config.gr. Uncomment these lines:
executable:${TEXTTEST_HOME}/js-mocha/test/texttest_fixture.js
interpreter:node