-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
64d826b
commit 322b400
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { getTestServer } from "fake-snippets-api/tests/fixtures/get-test-server" | ||
import { test, expect } from "bun:test" | ||
|
||
test("get order file", async () => { | ||
const { | ||
axios, | ||
seed: { | ||
order: { order_id }, | ||
}, | ||
} = await getTestServer() | ||
|
||
const file = new File(["test file content"], "test.txt", { | ||
type: "text/plain", | ||
}) | ||
const uploadResponse = await axios.post("/api/order_files/upload", { | ||
order_id, | ||
file, | ||
is_gerbers_zip: false, | ||
}) | ||
|
||
const orderFileId = uploadResponse.data.order_file.order_file_id | ||
|
||
const response = await axios.get("/api/order_files/get", { | ||
params: { order_file_id: orderFileId }, | ||
}) | ||
|
||
expect(response.status).toBe(200) | ||
expect(response.data.order_file).toBeDefined() | ||
expect(response.data.order_file.order_file_id).toBe(orderFileId) | ||
expect(response.data.order_file.order_id).toBe(order_id) | ||
expect(response.data.order_file.file_name).toBe("test.txt") | ||
expect(response.data.order_file.file_size).toBe(18) | ||
expect(response.data.order_file.is_gerbers_zip).toBe(false) | ||
}) | ||
|
||
test("get non-existent order file", async () => { | ||
const { axios } = await getTestServer() | ||
|
||
try { | ||
await axios.get("/api/order_files/get", { | ||
params: { order_file_id: "non-existent-id" }, | ||
}) | ||
|
||
expect(true).toBe(false) | ||
} catch (error: any) { | ||
expect(error.status).toBe(404) | ||
expect(error.data.error.message).toBe("Order file not found") | ||
} | ||
}) |