Skip to content

Commit

Permalink
refactor: replace jest by vitest, and rework some existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bgatellier committed Jun 18, 2024
1 parent c258536 commit 9fdd274
Show file tree
Hide file tree
Showing 26 changed files with 1,011 additions and 3,732 deletions.
4 changes: 1 addition & 3 deletions .moon/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,4 @@ tasks:
affectedFiles: true
affectedPassInputs: true
test:
command: jest
env:
NODE_OPTIONS: --experimental-vm-modules
command: vitest run
189 changes: 0 additions & 189 deletions modules/api/jest.config.mjs

This file was deleted.

25 changes: 13 additions & 12 deletions modules/api/tests/ApiModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { describe, it, expect } from "vitest";
import { createServer } from "./build/CreateServer.js";
import { analysisModules } from "./data/AnalysisModules.js";
import { listenerModules } from "./data/ListenerModules.js";

describe("Start an analysis with an invalid request", () => {
test("Get a 404 status code with an invalid verb and path", async () => {
it("Get a 404 status code with an invalid verb and path", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -16,7 +17,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(404);
});

test("Get a 404 status code with an invalid verb but a valid path", async () => {
it("Get a 404 status code with an invalid verb but a valid path", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -29,7 +30,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(404);
});

test("Get a 404 status code with a valid verb but an invalid path", async () => {
it("Get a 404 status code with a valid verb but an invalid path", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -42,7 +43,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(404);
});

test("Get a 400 status code on POST /observatory with an missing body", async () => {
it("Get a 400 status code on POST /observatory with an missing body", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -55,7 +56,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(400);
});

test("Get a 400 status code on POST /observatory with an invalid format on the except_listeners property", async () => {
it("Get a 400 status code on POST /observatory with an invalid format on the except_listeners property", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -71,7 +72,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(400);
});

test("Get a 400 status code on POST /greenit with a valid format but an incorrect value on the except_listeners property", async () => {
it("Get a 400 status code on POST /greenit with a valid format but an incorrect value on the except_listeners property", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -87,7 +88,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(400);
});

test("Get a 400 status code on POST /observatory with an invalid format on the only_listeners property", async () => {
it("Get a 400 status code on POST /observatory with an invalid format on the only_listeners property", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -103,7 +104,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(400);
});

test("Get a 400 status code on POST /greenit with a valid format but an incorrect value on the only_listeners property", async () => {
it("Get a 400 status code on POST /greenit with a valid format but an incorrect value on the only_listeners property", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -119,7 +120,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(400);
});

test("Get a 400 status code on POST /greenit with an invalid threshold format", async () => {
it("Get a 400 status code on POST /greenit with an invalid threshold format", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -136,7 +137,7 @@ describe("Start an analysis with an invalid request", () => {
expect(response.statusCode).toBe(400);
});

test("Get a 400 status code on POST /greenit with a valid threshold format but an incorrect value", async () => {
it("Get a 400 status code on POST /greenit with a valid threshold format but an incorrect value", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -154,7 +155,7 @@ describe("Start an analysis with an invalid request", () => {
});

describe("Start an analysis with a valid request", () => {
test("Get a 200 status code on POST /greenit with a valid body", async () => {
it("Get a 200 status code on POST /greenit with a valid body", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand All @@ -172,7 +173,7 @@ describe("Start an analysis with a valid request", () => {
expect(response.statusCode).toBe(200);
});

test("Get a 200 status code on POST /observatory with a valid body", async () => {
it("Get a 200 status code on POST /observatory with a valid body", async () => {
const fastify = await createServer(analysisModules, listenerModules);

const response = await fastify.inject({
Expand Down
Loading

0 comments on commit 9fdd274

Please sign in to comment.