File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export async function listJobs() {
55}
66
77export 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}
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments