mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-04 09:11:39 +00:00
Updated readme.md file to include some extra explanations
This commit is contained in:
parent
1b80c27e67
commit
7e73f3bd48
@ -2,6 +2,18 @@
|
||||
|
||||
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
|
||||
@ -12,46 +24,14 @@ npm install
|
||||
|
||||
## Run the unit tests from the Command-Line
|
||||
|
||||
There are two unit test frameworks to choose from, Jest and Mocha.
|
||||
I chose to use Jest for unit tests and snapshot tests.
|
||||
|
||||
```sh
|
||||
npm run test:jest
|
||||
npm run test
|
||||
```
|
||||
|
||||
To run all tests in watch mode
|
||||
|
||||
```sh
|
||||
npm run test:jest:watch
|
||||
npm run test:watch
|
||||
```
|
||||
|
||||
Mocha
|
||||
|
||||
```sh
|
||||
npm run test:mocha
|
||||
```
|
||||
|
||||
|
||||
## Run the TextTest fixture from the Command-Line
|
||||
|
||||
_You may need to install `ts-node`_
|
||||
|
||||
```sh
|
||||
npx ts-node test/golden-master-text-test.ts
|
||||
```
|
||||
|
||||
Or with number of days as args:
|
||||
```sh
|
||||
npx ts-node test/golden-master-text-test.ts 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](../texttests/README.md) for setting up TextTest. You will need to specify the Python executable and interpreter in [config.gr](../texttests/config.gr). Uncomment these lines:
|
||||
|
||||
executable:${TEXTTEST_HOME}/python/texttest_fixture.py
|
||||
interpreter:python
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user