diff --git a/TypeScript/README.md b/TypeScript/README.md index 259e05fe..ab907807 100644 --- a/TypeScript/README.md +++ b/TypeScript/README.md @@ -10,23 +10,9 @@ Install dependencies npm install ``` -## Running app -_You may need to install `ts-node`_ +## Run the unit tests from the Command-Line -```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 -``` - -## Running tests - -To run all tests - -### Jest way +There are two unit test frameworks to choose from, Jest and Mocha. ```sh npm run test:jest @@ -38,8 +24,34 @@ To run all tests in watch mode npm run test:jest:watch ``` -### Mocha way +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 + + diff --git a/TypeScript/test/golden-master-text-test.ts b/TypeScript/test/golden-master-text-test.ts index 2259b975..378f78d5 100644 --- a/TypeScript/test/golden-master-text-test.ts +++ b/TypeScript/test/golden-master-text-test.ts @@ -1,5 +1,7 @@ import { Item, GildedRose } from '../app/gilded-rose'; +console.log("OMGHAI!") + const items = [ new Item("+5 Dexterity Vest", 10, 20), // new Item("Aged Brie", 2, 0), // @@ -20,11 +22,11 @@ if (process.argv.length > 2) { days = +process.argv[2]; } -for (let i = 0; i < days; i++) { +for (let i = 0; i < days + 1; i++) { console.log("-------- day " + i + " --------"); console.log("name, sellIn, quality"); items.forEach(element => { - console.log(element.name + ' ' + element.sellIn + ' ' + element.quality); + console.log(element.name + ', ' + element.sellIn + ', ' + element.quality); }); console.log(); diff --git a/TypeScript/texttest_rig.py b/TypeScript/texttest_rig.py new file mode 100644 index 00000000..0cd59ad1 --- /dev/null +++ b/TypeScript/texttest_rig.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +""" +This script uses npx to execute the TextTest Fixture for TypeScript. +It is designed to be used by TextTest and specified in the file 'texttests/config.gr' in this repo. +It is more convenient for TextTest to use since npx needs +several arguments in addition to the one the TextTest fixture needs. +""" +import os +import subprocess +import sys + +args = " ".join(sys.argv[1:]) +TEXTTEST_HOME = os.environ.get("TEXTTEST_HOME", os.getcwd()) +subprocess.run(f"npx ts-node {TEXTTEST_HOME}/TypeScript/test/golden-master-text-test.ts {args}", shell=True) diff --git a/texttests/config.gr b/texttests/config.gr index e51dc368..a496bb8a 100755 --- a/texttests/config.gr +++ b/texttests/config.gr @@ -32,8 +32,8 @@ diff_program:meld #interpreter:perl # Settings for the TypeScript version -#executable:${TEXTTEST_HOME}/TypeScript/test/golden-master-text-test.js -#interpreter:node +#executable:${TEXTTEST_HOME}/TypeScript/texttest_rig.py +#interpreter:python # Settings for the Julia version #executable:${TEXTTEST_HOME}/julia/texttest_fixture.jl