11import { jest } from "@jest/globals"
2- import dotenv from "dotenv"
3- dotenv . config ( )
4-
5- // Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
2+ // dotenv.config() is no longer needed; config module handles environment loading
63import express from "express"
74import request from "supertest"
85import controller from '../../db-controller.js'
6+ import config from '../../config/index.js'
7+
8+ // Only real way to test an express route is to mount it and call it so that we can use the req, res, next.
99
1010// Here is the auth mock so we get a req.user and the controller can function without a NPE.
1111const addAuth = ( req , res , next ) => {
@@ -24,12 +24,12 @@ const unique = new Date(Date.now()).toISOString().replace("Z", "")
2424it ( "'/set' route functions" , async ( ) => {
2525 const response = await request ( routeTester )
2626 . patch ( "/set" )
27- . send ( { "@id" :`${ process . env . RERUM_ID_PREFIX } 11111` , "test_set" :unique } )
27+ . send ( { "@id" :`${ config . RERUM_ID_PREFIX } 11111` , "test_set" :unique } )
2828 . set ( 'Content-Type' , 'application/json; charset=utf-8' )
2929 . then ( resp => resp )
3030 . catch ( err => err )
3131 expect ( response . header . location ) . toBe ( response . body [ "@id" ] )
32- expect ( response . headers [ "location" ] ) . not . toBe ( `${ process . env . RERUM_ID_PREFIX } 11111` )
32+ expect ( response . headers [ "location" ] ) . not . toBe ( `${ config . RERUM_ID_PREFIX } 11111` )
3333 expect ( response . statusCode ) . toBe ( 200 )
3434 expect ( response . body . _id ) . toBeUndefined ( )
3535 expect ( response . body [ "test_set" ] ) . toBe ( unique )
0 commit comments