22 lines
809 B
JavaScript
22 lines
809 B
JavaScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { forwardMarketBatch } from "../vite.config.js";
|
|
|
|
test("keeps the import token in the local server-side forwarder", async () => {
|
|
let forwarded;
|
|
const response = await forwardMarketBatch('{"batchId":"one"}', {
|
|
url: "https://l2.example/api/l2/market/import",
|
|
token: "secret",
|
|
fetchImpl: async (url, init) => {
|
|
forwarded = { url, init };
|
|
return Response.json({ imported: true });
|
|
},
|
|
});
|
|
|
|
assert.equal(response.status, 200);
|
|
assert.equal(forwarded.url, "https://l2.example/api/l2/market/import");
|
|
assert.equal(forwarded.init.headers.Authorization, "Bearer secret");
|
|
assert.equal(forwarded.init.body, '{"batchId":"one"}');
|
|
assert.equal((await forwardMarketBatch("{}", {})).status, 503);
|
|
});
|