From a6b8c9f8940cd248756ecf2f48c88b7777e17d55 Mon Sep 17 00:00:00 2001 From: Bikossor Date: Sun, 4 Feb 2024 12:12:19 +0100 Subject: [PATCH] test: adjust tests and move file into src folder #306 --- packages/anonymus/src/anonymus.test.ts | 8 +++++ packages/anonymus/test/anonymus.test.ts | 43 ------------------------- 2 files changed, 8 insertions(+), 43 deletions(-) create mode 100644 packages/anonymus/src/anonymus.test.ts delete mode 100644 packages/anonymus/test/anonymus.test.ts diff --git a/packages/anonymus/src/anonymus.test.ts b/packages/anonymus/src/anonymus.test.ts new file mode 100644 index 0000000..31bc4bc --- /dev/null +++ b/packages/anonymus/src/anonymus.test.ts @@ -0,0 +1,8 @@ +import { expect, it } from "vitest"; +import { createAnonymusGenerator } from "./anonymus"; + +it("should return two words separated by a whitespace", () => { + const anonymus = createAnonymusGenerator(); + + expect(anonymus.next().value).toMatch(/^\w+\s\w+$/); +}); diff --git a/packages/anonymus/test/anonymus.test.ts b/packages/anonymus/test/anonymus.test.ts deleted file mode 100644 index a32383e..0000000 --- a/packages/anonymus/test/anonymus.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { expect, test } from "vitest"; -import { create } from "../dist/anonymus"; - -test(`create() => An array including a string matching 2 words seperated by a space`, () => { - const testResult = create(); - - expect(testResult.length).toBe(1); - - expect(testResult[0]).toMatch(/^\w+\s\w+$/); -}); - -test(`create("1") => Should throw an error`, () => { - expect(() => { - // @ts-expect-error - create("1"); - }).toThrow(); -}); - -test(`create(Infinity) => Should throw an error`, () => { - expect(() => { - create(Infinity); - }).toThrow(); -}); - -test(`create(1) => An array including 1 string matching 2 words seperated by a space`, () => { - const testResult = create(1); - - testResult.forEach((entry) => { - expect(entry).toMatch(/^\w+\s\w+$/); - }); - - expect(testResult.length).toBe(1); -}); - -test(`create(10) => An array including 10 strings mathing 2 words seperated by a space`, () => { - const testResult = create(10); - - testResult.forEach((entry) => { - expect(entry).toMatch(/^\w+\s\w+$/); - }); - - expect(testResult.length).toBe(10); -});