base de datos de orders con repositorio y test
This commit is contained in:
35
packages/sim-shared/infrastructure/OrderRepository.test.ts
Normal file
35
packages/sim-shared/infrastructure/OrderRepository.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
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))
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user