File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change 1+ import { describe , expect , test } from "bun:test" ;
2+ import { Hono } from "hono" ;
3+
4+ process . env . DATABASE_URL = ":memory:" ;
5+ const { dropRouter } = await import ( "../src/routes/drop" ) ;
6+ const app = new Hono ( ) ;
7+ app . route ( "/api" , dropRouter ) ;
8+
9+ describe ( "Upload validation shapes" , ( ) => {
10+ test ( "missing file returns error with message" , async ( ) => {
11+ const res = await app . request ( "/api/upload" , { method : "POST" } ) ;
12+ expect ( res . status ) . toBe ( 400 ) ;
13+ const json = await res . json ( ) ;
14+ expect ( json ) . toHaveProperty ( "error" ) ;
15+ expect ( json . error . length ) . toBeGreaterThan ( 5 ) ;
16+ } ) ;
17+
18+ test ( "empty file returns specific error" , async ( ) => {
19+ const formData = new FormData ( ) ;
20+ formData . append ( "file" , new File ( [ ] , "empty.txt" ) ) ;
21+ const res = await app . request ( "/api/upload" , { method : "POST" , body : formData } ) ;
22+ expect ( res . status ) . toBe ( 400 ) ;
23+ const json = await res . json ( ) ;
24+ expect ( json . error ) . toContain ( "empty" ) ;
25+ } ) ;
26+ } ) ;
You can’t perform that action at this time.
0 commit comments