From f541a988382c2f92643b888f512c6f230f64a3c6 Mon Sep 17 00:00:00 2001 From: Nadine Date: Thu, 9 Jan 2025 19:54:34 -0400 Subject: [PATCH] port typescript approval tests from jest to vitest --- TypeScript/test/vitest/approvals.spec.ts | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 TypeScript/test/vitest/approvals.spec.ts diff --git a/TypeScript/test/vitest/approvals.spec.ts b/TypeScript/test/vitest/approvals.spec.ts new file mode 100644 index 00000000..858f4a22 --- /dev/null +++ b/TypeScript/test/vitest/approvals.spec.ts @@ -0,0 +1,30 @@ +import { execSync } from 'node:child_process'; +import { Item, GildedRose } from '@/gilded-rose'; + +/** + * This test uses Vitest Snapshot, similar to [Jest Snapshot](https://goo.gl/fbAQLP). + * + * There are two test cases here with different styles: + *
  • "foo" is more similar to the unit test from the 'Java' version + *
  • "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', () => { + it('should foo', () => { + const gildedRose = new GildedRose([new Item('foo', 0, 0)]); + const items = gildedRose.updateQuality(); + + expect(items).toMatchSnapshot(); + }); + + it('should thirtyDays', () => { + const consoleOutput = execSync( + 'ts-node test/golden-master-text-test.ts 30', + { encoding: 'utf-8' } + ); + + expect(consoleOutput).toMatchSnapshot(); + }); +});