Skip to content

Commit 6963897

Browse files
committed
fix(api): enforce open status for new jobs
1 parent 0c055f1 commit 6963897

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

apps/api/src/services/jobService.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export async function listJobs() {
55
}
66

77
export async function createJob(payload) {
8-
const job = { id: `job_${Date.now()}`, status: "open", ...payload };
8+
const job = { id: `job_${Date.now()}`, ...payload, status: "OPEN" };
99
jobs.push(job);
1010
return job;
1111
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import test from "node:test";
2+
import assert from "node:assert/strict";
3+
import { createJob } from "../services/jobService.js";
4+
5+
function validJobPayload(overrides = {}) {
6+
return {
7+
title: "API integration",
8+
description: "Connect the service to a partner API.",
9+
budgetMin: 100,
10+
budgetMax: 500,
11+
categoryId: "cat_backend",
12+
skills: ["node", "api"],
13+
...overrides,
14+
};
15+
}
16+
17+
test("createJob initializes jobs with the OPEN status", async () => {
18+
const job = await createJob(validJobPayload());
19+
20+
assert.equal(job.status, "OPEN");
21+
});
22+
23+
test("createJob does not allow payload status to override the initial state", async () => {
24+
const job = await createJob(validJobPayload({ status: "COMPLETED" }));
25+
26+
assert.equal(job.status, "OPEN");
27+
});

0 commit comments

Comments
 (0)