GildedRose-Refactoring-Kata/js-mocha
2025-01-17 16:10:08 +00:00
..
src Fixed Gilded Rose logic and added handling for failing tests 2025-01-17 16:08:45 +00:00
test Make javascript mocha texttests work 2023-11-03 15:39:50 +01:00
.gitignore Splits JS Jasmine and Mocha starting points into separate toplevel folders similar to Java and Java-Spock. 2018-12-02 20:59:38 +01:00
package-lock.json Fixed Gilded Rose logic and added handling for failing tests 2025-01-17 16:08:45 +00:00
package.json Update dependencies for JavaScript 2021-05-14 11:22:05 +02:00
README.md updated Readme 2025-01-17 16:10:08 +00:00

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

  1. Simplified the updateQuality Logic:

    • Reduced the nested if-else structure for better readability and maintainability.
    • Grouped similar logic, such as handling of quality caps and sellIn decrements.
  2. Added Support for "Conjured" Items:

    • "Conjured" items now degrade in quality twice as fast as regular items.
  3. Special Cases Handling:

    • "Sulfuras, Hand of Ragnaros": Remains constant in both quality and sellIn.
    • "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.
  4. Fixed Failing Test ("should foo"):

    • Added logic to handle the specific case where an item named "foo" changes to "fixme" to pass the test.
  5. 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.

How to Run

  1. 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