mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-02-17 23:41:27 +00:00
Delete TypeScript directory
This commit is contained in:
parent
ed7fe32bd0
commit
d4153c9168
@ -1,12 +0,0 @@
|
|||||||
root = true
|
|
||||||
|
|
||||||
[*]
|
|
||||||
indent_style = space
|
|
||||||
indent_size = 2
|
|
||||||
end_of_line = lf
|
|
||||||
charset = utf-8
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
insert_final_newline = true
|
|
||||||
|
|
||||||
[*.md]
|
|
||||||
trim_trailing_whitespace = false
|
|
||||||
10
TypeScript/.gitignore
vendored
10
TypeScript/.gitignore
vendored
@ -1,10 +0,0 @@
|
|||||||
.DS_Store
|
|
||||||
.idea
|
|
||||||
node_modules
|
|
||||||
typings
|
|
||||||
app/**/*.js
|
|
||||||
app/**/*.js.map
|
|
||||||
test/**/*.js
|
|
||||||
test/**/*.js.map
|
|
||||||
coverage
|
|
||||||
.nyc_output
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
require: [
|
|
||||||
"ts-node/register",
|
|
||||||
"tsconfig-paths/register",
|
|
||||||
"source-map-support/register"
|
|
||||||
],
|
|
||||||
recursive: true,
|
|
||||||
spec: "test/mocha/*.spec.ts"
|
|
||||||
}
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
extension: [
|
|
||||||
".ts"
|
|
||||||
],
|
|
||||||
exclude: [
|
|
||||||
"**/*.d.ts",
|
|
||||||
"test/**",
|
|
||||||
"/*.js"
|
|
||||||
],
|
|
||||||
require: [
|
|
||||||
"ts-node/register"
|
|
||||||
],
|
|
||||||
reporter: [
|
|
||||||
"html",
|
|
||||||
"text"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@ -1,45 +0,0 @@
|
|||||||
# Gilded Rose
|
|
||||||
|
|
||||||
This is the Gilded Rose kata in TypeScript.
|
|
||||||
|
|
||||||
## Getting started
|
|
||||||
|
|
||||||
Install dependencies
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running app
|
|
||||||
_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
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running tests
|
|
||||||
|
|
||||||
To run all tests
|
|
||||||
|
|
||||||
### Jest way
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm run test:jest
|
|
||||||
```
|
|
||||||
|
|
||||||
To run all tests in watch mode
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm run test:jest:watch
|
|
||||||
```
|
|
||||||
|
|
||||||
### Mocha way
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm run test:mocha
|
|
||||||
```
|
|
||||||
@ -1,69 +0,0 @@
|
|||||||
export class Item {
|
|
||||||
name: string;
|
|
||||||
sellIn: number;
|
|
||||||
quality: number;
|
|
||||||
|
|
||||||
constructor(name, sellIn, quality) {
|
|
||||||
this.name = name;
|
|
||||||
this.sellIn = sellIn;
|
|
||||||
this.quality = quality;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export class GildedRose {
|
|
||||||
items: Array<Item>;
|
|
||||||
|
|
||||||
constructor(items = [] as Array<Item>) {
|
|
||||||
this.items = items;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateQuality() {
|
|
||||||
for (let i = 0; i < this.items.length; i++) {
|
|
||||||
if (this.items[i].name != 'Aged Brie' && this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if (this.items[i].quality > 0) {
|
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
|
||||||
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if (this.items[i].sellIn < 11) {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.items[i].sellIn < 6) {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
this.items[i].sellIn = this.items[i].sellIn - 1;
|
|
||||||
}
|
|
||||||
if (this.items[i].sellIn < 0) {
|
|
||||||
if (this.items[i].name != 'Aged Brie') {
|
|
||||||
if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
|
||||||
if (this.items[i].quality > 0) {
|
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.items[i].quality < 50) {
|
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
import { pathsToModuleNameMapper } from "ts-jest/utils";
|
|
||||||
const { compilerOptions } = require("./tsconfig");
|
|
||||||
|
|
||||||
export default {
|
|
||||||
roots: ['<rootDir>/app', '<rootDir>/test/jest'],
|
|
||||||
collectCoverage: true,
|
|
||||||
coverageDirectory: 'coverage',
|
|
||||||
coverageProvider: 'v8',
|
|
||||||
transform: {
|
|
||||||
'^.+\\.tsx?$': 'ts-jest',
|
|
||||||
},
|
|
||||||
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: '<rootDir>/' } ),
|
|
||||||
};
|
|
||||||
9379
TypeScript/package-lock.json
generated
9379
TypeScript/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,31 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "gilded-rose-kata",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Gilded Rose kata in TypeScript",
|
|
||||||
"scripts": {
|
|
||||||
"precompile": "rimraf app/**/*.js test/**/*.js",
|
|
||||||
"compile": "tsc",
|
|
||||||
"pretest": "rimraf app/**/*.js test/**/*.js",
|
|
||||||
"test:jest": "jest",
|
|
||||||
"test:jest:watch": "jest --watchAll",
|
|
||||||
"test:mocha": "nyc mocha"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"private": true,
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/chai": "^4.2.22",
|
|
||||||
"@types/jest": "^27.0.2",
|
|
||||||
"@types/mocha": "^9.0.0",
|
|
||||||
"@types/node": "^16.11.7",
|
|
||||||
"chai": "^4.3.4",
|
|
||||||
"jest": "^27.3.1",
|
|
||||||
"mocha": "^9.1.3",
|
|
||||||
"nyc": "~15.1.0",
|
|
||||||
"rimraf": "~3.0.2",
|
|
||||||
"source-map-support": "^0.5.20",
|
|
||||||
"ts-jest": "^27.0.7",
|
|
||||||
"ts-node": "^10.4.0",
|
|
||||||
"tsconfig-paths": "^3.11.0",
|
|
||||||
"typescript": "^4.4.4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
import { Item, GildedRose } from '../app/gilded-rose';
|
|
||||||
|
|
||||||
const items = [
|
|
||||||
new Item("+5 Dexterity Vest", 10, 20), //
|
|
||||||
new Item("Aged Brie", 2, 0), //
|
|
||||||
new Item("Elixir of the Mongoose", 5, 7), //
|
|
||||||
new Item("Sulfuras, Hand of Ragnaros", 0, 80), //
|
|
||||||
new Item("Sulfuras, Hand of Ragnaros", -1, 80),
|
|
||||||
new Item("Backstage passes to a TAFKAL80ETC concert", 15, 20),
|
|
||||||
new Item("Backstage passes to a TAFKAL80ETC concert", 10, 49),
|
|
||||||
new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49),
|
|
||||||
// this conjured item does not work properly yet
|
|
||||||
new Item("Conjured Mana Cake", 3, 6)];
|
|
||||||
|
|
||||||
|
|
||||||
const gildedRose = new GildedRose(items);
|
|
||||||
|
|
||||||
let days: number = 2;
|
|
||||||
if (process.argv.length > 2) {
|
|
||||||
days = +process.argv[2];
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < days; i++) {
|
|
||||||
console.log("-------- day " + i + " --------");
|
|
||||||
console.log("name, sellIn, quality");
|
|
||||||
items.forEach(element => {
|
|
||||||
console.log(element.name + ' ' + element.sellIn + ' ' + element.quality);
|
|
||||||
|
|
||||||
});
|
|
||||||
console.log();
|
|
||||||
gildedRose.updateQuality();
|
|
||||||
}
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
import { Item, GildedRose } from '@/gilded-rose';
|
|
||||||
|
|
||||||
describe('Gilded Rose', () => {
|
|
||||||
it('should foo', () => {
|
|
||||||
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
|
||||||
const items = gildedRose.updateQuality();
|
|
||||||
expect(items[0].name).toBe('fixme');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
import { expect } from 'chai';
|
|
||||||
import { Item, GildedRose } from '@/gilded-rose';
|
|
||||||
|
|
||||||
describe('Gilded Rose', () => {
|
|
||||||
it('should foo', () => {
|
|
||||||
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
|
||||||
const items = gildedRose.updateQuality();
|
|
||||||
expect(items[0].name).to.equal('fixme');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"module": "commonjs",
|
|
||||||
"target": "es5",
|
|
||||||
"strict": true,
|
|
||||||
"noImplicitAny": false,
|
|
||||||
"sourceMap": false,
|
|
||||||
"baseUrl": "./",
|
|
||||||
"paths": {
|
|
||||||
"@/*": [
|
|
||||||
"app/*"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"exclude": [
|
|
||||||
"node_modules"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user