mirror of
https://github.com/Mercantec-GHC/h4-projekt-gruppe-0-sm.git
synced 2025-04-27 16:24:07 +02:00
fix receipts one
This commit is contained in:
parent
6367631294
commit
ec520c330a
@ -59,6 +59,7 @@ void route_get_receipts_one(HttpCtx* ctx)
|
||||
.product_id = products.data[i].id,
|
||||
.name = str_dup(products.data[i].name),
|
||||
.price_dkk_cent = product_prices.data[i].price_dkk_cent,
|
||||
.amount = receipt.products.data[i].amount,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -310,10 +310,10 @@ char* receipts_one_res_product_to_json_string(const ReceiptsOneResProduct* m)
|
||||
string_construct(&string);
|
||||
string_pushf(&string,
|
||||
"{"
|
||||
"\"product_id\":\"%ld\","
|
||||
"\"product_id\":%ld,"
|
||||
"\"name\":\"%s\","
|
||||
"\"price_dkk_cent\":\"%ld\","
|
||||
"\"price_dkk_cent\":\"%ld\""
|
||||
"\"price_dkk_cent\":%ld,"
|
||||
"\"amount\":%ld"
|
||||
"}",
|
||||
m->product_id,
|
||||
m->name,
|
||||
@ -333,9 +333,9 @@ char* receipts_one_res_to_json_string(const ReceiptsOneRes* m)
|
||||
string_construct(&string);
|
||||
string_pushf(&string,
|
||||
"{"
|
||||
"\"receipt_id\":\"%ld\","
|
||||
"\"receipt_id\":%ld,"
|
||||
"\"timestamp\":\"%s\","
|
||||
"\"products:\":[",
|
||||
"\"products\":[",
|
||||
m->receipt_id,
|
||||
m->timestamp);
|
||||
|
||||
|
@ -107,13 +107,21 @@ async function testCartsAndReceipts(t: Deno.TestContext, token: string) {
|
||||
});
|
||||
|
||||
await t.step("test /api/receipts/all", async () => {
|
||||
const res = await get<{ ok: boolean }>(
|
||||
const res = await get<{
|
||||
ok: boolean;
|
||||
receipts: { timestamp: string }[];
|
||||
}>(
|
||||
`/api/receipts/all`,
|
||||
{ "Session-Token": token },
|
||||
);
|
||||
|
||||
console.log(res);
|
||||
// console.log(res);
|
||||
assertEquals(res.ok, true);
|
||||
assertEquals(res.receipts.length, 1);
|
||||
assertMatch(
|
||||
res.receipts[0].timestamp,
|
||||
/\d{4}-[01]\d-[0-3]\d [0-2]\d:[0-5]\d:[0-5]\d/,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user