36 lines
995 B
TypeScript
36 lines
995 B
TypeScript
import { describe, it } from "node:test";
|
|
import { OrderRepository } from "./OrderRepository.js";
|
|
import { CreateOrderDTO } from "../domain/Order.js";
|
|
import { postgresClient } from "../config/config.test.js";
|
|
import assert from "node:assert";
|
|
|
|
const order1 = <CreateOrderDTO>{
|
|
correlation_id: "fakeRMQid-1234",
|
|
exchange: "fake.ex",
|
|
routing_key: "test.order.idk",
|
|
order_type: "activate",
|
|
payload: { iccid: "1234", action: "activate" }
|
|
}
|
|
|
|
|
|
describe("Test OrderRepository", {}, () => {
|
|
const orderRepo = new OrderRepository(postgresClient)
|
|
|
|
|
|
it("Insert new Order", async () => {
|
|
const newOrder = order1
|
|
const result = await orderRepo.createOrder(newOrder)
|
|
|
|
assert(result.error == undefined)
|
|
assert(result.data != undefined)
|
|
|
|
const order = result.data!
|
|
|
|
assert(order.id != undefined)
|
|
assert(order.correlation_id == newOrder.correlation_id)
|
|
assert(order.status == 'pending')
|
|
|
|
console.log("[T] Creada Order", typeof (result.data.start_date))
|
|
})
|
|
})
|