From b6807bf9fc8639c52fd2e060c9854e347a6a3c87 Mon Sep 17 00:00:00 2001 From: Zeger Hendrikse Date: Mon, 21 Oct 2024 13:57:05 +0200 Subject: [PATCH] Added jest reporter to approval tests --- .../1-golden-master/spec/gilded-rose.spec.ts | 8 ++++++++ .../2-lift-up-conditional/spec/gilded-rose.spec.ts | 11 ++++++++++- .../3-gilded-rose-refactored/spec/gilded-rose.spec.ts | 8 ++++++++ .../gilded-rose-typescript/instructions.md | 10 ++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/kata-solutions/gilded-rose-kata/gilded-rose-typescript/1-golden-master/spec/gilded-rose.spec.ts b/kata-solutions/gilded-rose-kata/gilded-rose-typescript/1-golden-master/spec/gilded-rose.spec.ts index dc64a66..68bda92 100644 --- a/kata-solutions/gilded-rose-kata/gilded-rose-typescript/1-golden-master/spec/gilded-rose.spec.ts +++ b/kata-solutions/gilded-rose-kata/gilded-rose-typescript/1-golden-master/spec/gilded-rose.spec.ts @@ -2,6 +2,8 @@ import { Item, GildedRose } from '../src/gilded-rose'; import { verify } from "approvals/lib/Providers/Jest/JestApprovals"; +import { configure } from "approvals/lib/config"; +import { JestReporter } from "approvals/lib/Providers/Jest/JestReporter"; function convert_items_to_string(items = [] as Array) { let items_as_string = items.map((item) => item.toString() + "\n") @@ -12,6 +14,12 @@ function convert_items_to_string(items = [] as Array) { } describe('Gilded Rose', () => { + beforeAll(() => { + configure({ + reporters: [new JestReporter()], + }); + }); + it('updates a foo item', () => { const items = [ new Item("Foo", 0, 0), diff --git a/kata-solutions/gilded-rose-kata/gilded-rose-typescript/2-lift-up-conditional/spec/gilded-rose.spec.ts b/kata-solutions/gilded-rose-kata/gilded-rose-typescript/2-lift-up-conditional/spec/gilded-rose.spec.ts index 4df2701..ce20c92 100644 --- a/kata-solutions/gilded-rose-kata/gilded-rose-typescript/2-lift-up-conditional/spec/gilded-rose.spec.ts +++ b/kata-solutions/gilded-rose-kata/gilded-rose-typescript/2-lift-up-conditional/spec/gilded-rose.spec.ts @@ -1,7 +1,10 @@ + 'use strict'; import { Item, GildedRose } from '../src/gilded-rose'; import { verify } from "approvals/lib/Providers/Jest/JestApprovals"; +import { configure } from "approvals/lib/config"; +import { JestReporter } from "approvals/lib/Providers/Jest/JestReporter"; function convert_items_to_string(items = [] as Array) { let items_as_string = items.map((item) => item.toString() + "\n") @@ -12,6 +15,12 @@ function convert_items_to_string(items = [] as Array) { } describe('Gilded Rose', () => { + beforeAll(() => { + configure({ + reporters: [new JestReporter()], + }); + }); + it('updates a foo item', () => { const items = [ new Item("Foo", 0, 0), @@ -34,7 +43,7 @@ describe('Gilded Rose', () => { new Item("Backstage passes to a TAFKAL80ETC concert", 5, 48), new Item("Backstage passes to a TAFKAL80ETC concert", 5, 49), new Item("Backstage passes to a TAFKAL80ETC concert", 6, 47), - new Item("Backstage passes to a TAFKAL80ETC concert", 0, 50), + new Item("Backstage passes to a TAFKAL80ETC concert", 0, 50) ]; const gildedRose = new GildedRose(items); const updated_items = gildedRose.updateQuality(); diff --git a/kata-solutions/gilded-rose-kata/gilded-rose-typescript/3-gilded-rose-refactored/spec/gilded-rose.spec.ts b/kata-solutions/gilded-rose-kata/gilded-rose-typescript/3-gilded-rose-refactored/spec/gilded-rose.spec.ts index 0b06889..1cbd7d7 100644 --- a/kata-solutions/gilded-rose-kata/gilded-rose-typescript/3-gilded-rose-refactored/spec/gilded-rose.spec.ts +++ b/kata-solutions/gilded-rose-kata/gilded-rose-typescript/3-gilded-rose-refactored/spec/gilded-rose.spec.ts @@ -2,6 +2,8 @@ import { Item, GildedRose, Sulfuras, BackstagePass, AgedBrie } from '../src/gilded-rose'; import { verify } from "approvals/lib/Providers/Jest/JestApprovals"; +import { configure } from "approvals/lib/config"; +import { JestReporter } from "approvals/lib/Providers/Jest/JestReporter"; function convert_items_to_string(items = [] as Array) { let items_as_string = items.map((item) => item.toString() + "\n") @@ -12,6 +14,12 @@ function convert_items_to_string(items = [] as Array) { } describe('Gilded Rose', () => { + beforeAll(() => { + configure({ + reporters: [new JestReporter()], + }); + }); + it('updates a foo item', () => { const items = [ new Item("Foo", 0, 0), diff --git a/tdd-katas/gilded-rose-kata/gilded-rose-typescript/instructions.md b/tdd-katas/gilded-rose-kata/gilded-rose-typescript/instructions.md index de1f1ea..e10fe47 100644 --- a/tdd-katas/gilded-rose-kata/gilded-rose-typescript/instructions.md +++ b/tdd-katas/gilded-rose-kata/gilded-rose-typescript/instructions.md @@ -51,6 +51,10 @@ npm run test Using the approval test framework ```typescript +import { verify } from "approvals/lib/Providers/Jest/JestApprovals"; +import { configure } from "approvals/lib/config"; +import { JestReporter } from "approvals/lib/Providers/Jest/JestReporter"; + function convert_items_to_string(items = [] as Array) { let items_as_string = items.map((item) => item.toString() + "\n") return items_as_string.reduce( @@ -60,6 +64,12 @@ function convert_items_to_string(items = [] as Array) { } describe('Gilded Rose', () => { + beforeAll(() => { + configure({ + reporters: [new JestReporter()], + }); + }); + it('updates a foo item', () => { const items = [ new Item("Foo", 0, 0)