mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
test: set up Deno version test cases
This commit is contained in:
parent
f86e41151c
commit
3690af35f9
@ -3,7 +3,7 @@ export class Item {
|
|||||||
sellIn: number;
|
sellIn: number;
|
||||||
quality: number;
|
quality: number;
|
||||||
|
|
||||||
constructor(name, sellIn, quality) {
|
constructor(name: string, sellIn: number, quality: number) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.sellIn = sellIn;
|
this.sellIn = sellIn;
|
||||||
this.quality = quality;
|
this.quality = quality;
|
||||||
@ -19,46 +19,54 @@ export class GildedRose {
|
|||||||
|
|
||||||
updateQuality() {
|
updateQuality() {
|
||||||
for (let i = 0; i < this.items.length; i++) {
|
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].name != "Aged Brie" &&
|
||||||
|
this.items[i].name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
) {
|
||||||
if (this.items[i].quality > 0) {
|
if (this.items[i].quality > 0) {
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
if (this.items[i].name != "Sulfuras, Hand of Ragnaros") {
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
this.items[i].quality = this.items[i].quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.items[i].quality < 50) {
|
if (this.items[i].quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
this.items[i].quality = this.items[i].quality + 1;
|
||||||
if (this.items[i].name == 'Backstage passes to a TAFKAL80ETC concert') {
|
if (
|
||||||
|
this.items[i].name == "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
) {
|
||||||
if (this.items[i].sellIn < 11) {
|
if (this.items[i].sellIn < 11) {
|
||||||
if (this.items[i].quality < 50) {
|
if (this.items[i].quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
this.items[i].quality = this.items[i].quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.items[i].sellIn < 6) {
|
if (this.items[i].sellIn < 6) {
|
||||||
if (this.items[i].quality < 50) {
|
if (this.items[i].quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
this.items[i].quality = this.items[i].quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
if (this.items[i].name != "Sulfuras, Hand of Ragnaros") {
|
||||||
this.items[i].sellIn = this.items[i].sellIn - 1;
|
this.items[i].sellIn = this.items[i].sellIn - 1;
|
||||||
}
|
}
|
||||||
if (this.items[i].sellIn < 0) {
|
if (this.items[i].sellIn < 0) {
|
||||||
if (this.items[i].name != 'Aged Brie') {
|
if (this.items[i].name != "Aged Brie") {
|
||||||
if (this.items[i].name != 'Backstage passes to a TAFKAL80ETC concert') {
|
if (
|
||||||
|
this.items[i].name != "Backstage passes to a TAFKAL80ETC concert"
|
||||||
|
) {
|
||||||
if (this.items[i].quality > 0) {
|
if (this.items[i].quality > 0) {
|
||||||
if (this.items[i].name != 'Sulfuras, Hand of Ragnaros') {
|
if (this.items[i].name != "Sulfuras, Hand of Ragnaros") {
|
||||||
this.items[i].quality = this.items[i].quality - 1
|
this.items[i].quality = this.items[i].quality - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.items[i].quality = this.items[i].quality - this.items[i].quality
|
this.items[i].quality = this.items[i].quality -
|
||||||
|
this.items[i].quality;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.items[i].quality < 50) {
|
if (this.items[i].quality < 50) {
|
||||||
this.items[i].quality = this.items[i].quality + 1
|
this.items[i].quality = this.items[i].quality + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,10 @@
|
|||||||
"version": "4",
|
"version": "4",
|
||||||
"specifiers": {
|
"specifiers": {
|
||||||
"jsr:@std/assert@1": "1.0.10",
|
"jsr:@std/assert@1": "1.0.10",
|
||||||
"jsr:@std/internal@^1.0.5": "1.0.5"
|
"jsr:@std/assert@^1.0.10": "1.0.10",
|
||||||
|
"jsr:@std/expect@*": "1.0.10",
|
||||||
|
"jsr:@std/internal@^1.0.5": "1.0.5",
|
||||||
|
"jsr:@std/testing@*": "1.0.8"
|
||||||
},
|
},
|
||||||
"jsr": {
|
"jsr": {
|
||||||
"@std/assert@1.0.10": {
|
"@std/assert@1.0.10": {
|
||||||
@ -11,8 +14,22 @@
|
|||||||
"jsr:@std/internal"
|
"jsr:@std/internal"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"@std/expect@1.0.10": {
|
||||||
|
"integrity": "7659b640447887cd1735f866962e10e434f12443b13595b149970c806e6f08db",
|
||||||
|
"dependencies": [
|
||||||
|
"jsr:@std/assert@^1.0.10",
|
||||||
|
"jsr:@std/internal"
|
||||||
|
]
|
||||||
|
},
|
||||||
"@std/internal@1.0.5": {
|
"@std/internal@1.0.5": {
|
||||||
"integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
|
"integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba"
|
||||||
|
},
|
||||||
|
"@std/testing@1.0.8": {
|
||||||
|
"integrity": "ceef535808fb7568e91b0f8263599bd29b1c5603ffb0377227f00a8ca9fe42a2",
|
||||||
|
"dependencies": [
|
||||||
|
"jsr:@std/assert@^1.0.10",
|
||||||
|
"jsr:@std/internal"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"workspace": {
|
"workspace": {
|
||||||
|
|||||||
12
deno/test/gilded-rose_test.ts
Normal file
12
deno/test/gilded-rose_test.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { describe, it } from "jsr:@std/testing/bdd";
|
||||||
|
import { expect } from "jsr:@std/expect";
|
||||||
|
|
||||||
|
import { GildedRose, Item } from "../app/gilded-rose.ts";
|
||||||
|
|
||||||
|
describe("Gilded Rose specifications", () => {
|
||||||
|
it("should foo", () => {
|
||||||
|
const gildedRose = new GildedRose([new Item("foo", 0, 0)]);
|
||||||
|
const items = gildedRose.updateQuality();
|
||||||
|
expect(items[0].name).toBe("fixme");
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -18,8 +18,8 @@ const items = [
|
|||||||
const gildedRose = new GildedRose(items);
|
const gildedRose = new GildedRose(items);
|
||||||
|
|
||||||
let days: number = 2;
|
let days: number = 2;
|
||||||
if (process.argv.length > 2) {
|
if (Deno.args.length > 0) {
|
||||||
days = +process.argv[2];
|
days = +Deno.args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < days + 1; i++) {
|
for (let i = 0; i < days + 1; i++) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user