@@ -5,9 +5,6 @@ import request from "supertest";
55import { app } from "./app.js" ;
66import { signupAndLogin } from "./src/utilities/testUtils.js" ;
77
8- const username = "test" + Math . random ( ) ;
9- const password = "p@$$w0rd!" ;
10-
118describe ( "/app" , ( ) => {
129 it ( "Insecure endpoint" , async ( ) => {
1310 // Insecure endpoint
@@ -29,6 +26,7 @@ describe("/app", () => {
2926 } ) ;
3027
3128 it ( "Secure endpoint with auth" , async ( ) => {
29+ const { username, password } = makeUsernameAndPassword ( ) ;
3230 const session = await signupAndLogin ( app , username , password , {
3331 email : "test@test.com" ,
3432 fullName : "Test User" ,
@@ -50,4 +48,27 @@ describe("/app", () => {
5048 } )
5149 ) ;
5250 } ) ;
51+
52+ it ( "404 on undefined api path" , async ( ) => {
53+ const { username, password } = makeUsernameAndPassword ( ) ;
54+ const session = await signupAndLogin ( app , username , password , {
55+ email : "test@test.com" ,
56+ fullName : "Test User" ,
57+ } ) ;
58+
59+ const token = session . token ;
60+
61+ const response = await request ( app )
62+ . get ( "/api/not-found" )
63+ . set ( "Accept" , "application/json" )
64+ . set ( "Authorization" , "Bearer " + token ) ;
65+
66+ expect ( response . status ) . toEqual ( 404 ) ;
67+ } ) ;
5368} ) ;
69+
70+ function makeUsernameAndPassword ( ) {
71+ const username = "test" + Math . random ( ) ;
72+ const password = "p@$$w0rd!" ;
73+ return { username, password } ;
74+ }
0 commit comments