Skip to content

Commit

Permalink
Added jest reporter to approval tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zhendrikse committed Oct 21, 2024
1 parent 49cfc70 commit b6807bf
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item>) {
let items_as_string = items.map((item) => item.toString() + "\n")
Expand All @@ -12,6 +14,12 @@ function convert_items_to_string(items = [] as Array<Item>) {
}

describe('Gilded Rose', () => {
beforeAll(() => {
configure({
reporters: [new JestReporter()],
});
});

it('updates a foo item', () => {
const items = [
new Item("Foo", 0, 0),
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Item>) {
let items_as_string = items.map((item) => item.toString() + "\n")
Expand All @@ -12,6 +15,12 @@ function convert_items_to_string(items = [] as Array<Item>) {
}

describe('Gilded Rose', () => {
beforeAll(() => {
configure({
reporters: [new JestReporter()],
});
});

it('updates a foo item', () => {
const items = [
new Item("Foo", 0, 0),
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Item>) {
let items_as_string = items.map((item) => item.toString() + "\n")
Expand All @@ -12,6 +14,12 @@ function convert_items_to_string(items = [] as Array<Item>) {
}

describe('Gilded Rose', () => {
beforeAll(() => {
configure({
reporters: [new JestReporter()],
});
});

it('updates a foo item', () => {
const items = [
new Item("Foo", 0, 0),
Expand Down
10 changes: 10 additions & 0 deletions tdd-katas/gilded-rose-kata/gilded-rose-typescript/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ npm run test
<summary>Using the approval test framework</summary>

```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<Item>) {
let items_as_string = items.map((item) => item.toString() + "\n")
return items_as_string.reduce(
Expand All @@ -60,6 +64,12 @@ function convert_items_to_string(items = [] as Array<Item>) {
}

describe('Gilded Rose', () => {
beforeAll(() => {
configure({
reporters: [new JestReporter()],
});
});

it('updates a foo item', () => {
const items = [
new Item("Foo", 0, 0)
Expand Down

0 comments on commit b6807bf

Please sign in to comment.