mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2026-10-16 02:53:57 +00:00
WIP: adding Deno version
This commit is contained in:
1 parent
11610e00ba
commit
d4514e6c9f
18 files changed
+414
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { GildedRose, Item } from "../app/gilded-rose.ts";
|
||||
|
||||
console.log("OMGHAI!");
|
||||
|
||||
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 + 1; 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();
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Item, GildedRose } from '@/gilded-rose';
|
||||
|
||||
/**
|
||||
* This unit test uses [Jest Snapshot](https://goo.gl/fbAQLP).
|
||||
*
|
||||
* There are two test cases here with different styles:
|
||||
* <li>"foo" is more similar to the unit test from the 'Java' version
|
||||
* <li>"thirtyDays" is more similar to the TextTest from the 'Java' version
|
||||
*
|
||||
* I suggest choosing one style to develop and deleting the other.
|
||||
*/
|
||||
|
||||
describe('Gilded Rose Approval', () => {
|
||||
|
||||
let gameConsoleOutput: string;
|
||||
let originalConsoleLog: (message: any) => void;
|
||||
let originalProcessArgv: string[]
|
||||
|
||||
function gameConsoleLog(msg: string) {
|
||||
if (msg) {
|
||||
gameConsoleOutput += msg;
|
||||
}
|
||||
gameConsoleOutput += "\n";
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
// prepare capturing console.log to our own gameConsoleLog.
|
||||
gameConsoleOutput = "";
|
||||
originalConsoleLog = console.log;
|
||||
console.log = gameConsoleLog;
|
||||
originalProcessArgv = process.argv;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// reset original console.log
|
||||
console.log = originalConsoleLog;
|
||||
process.argv = originalProcessArgv;
|
||||
});
|
||||
|
||||
it('should foo', () => {
|
||||
const gildedRose = new GildedRose([new Item('foo', 0, 0)]);
|
||||
const items = gildedRose.updateQuality();
|
||||
|
||||
expect(items).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should thirtyDays', () => {
|
||||
process.argv = ["<node>", "<script", "30"];
|
||||
require('../golden-master-text-test.ts');
|
||||
|
||||
expect(gameConsoleOutput).toMatchSnapshot();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
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');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user