Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/src/services/jobService.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export async function listJobs() {
}

export async function createJob(payload) {
const job = { id: `job_${Date.now()}`, status: "open", ...payload };
const job = { id: `job_${Date.now()}`, ...payload, status: "OPEN" };
jobs.push(job);
return job;
}
27 changes: 27 additions & 0 deletions apps/api/src/tests/jobService.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import test from "node:test";
import assert from "node:assert/strict";
import { createJob } from "../services/jobService.js";

function validJobPayload(overrides = {}) {
return {
title: "API integration",
description: "Connect the service to a partner API.",
budgetMin: 100,
budgetMax: 500,
categoryId: "cat_backend",
skills: ["node", "api"],
...overrides,
};
}

test("createJob initializes jobs with the OPEN status", async () => {
const job = await createJob(validJobPayload());

assert.equal(job.status, "OPEN");
});

test("createJob does not allow payload status to override the initial state", async () => {
const job = await createJob(validJobPayload({ status: "COMPLETED" }));

assert.equal(job.status, "OPEN");
});