fix: improves integration tests (#332)

* fix: improves integration tests

* fix: giftcard order with total 0

* fix: remove breaking eager
This commit is contained in:
Sebastian Rindom
2021-08-11 09:26:25 +02:00
committed by GitHub
parent 8edf8aacfa
commit 9a701ff229
23 changed files with 355 additions and 672 deletions
@@ -1,10 +1,9 @@
const { dropDatabase } = require("pg-god");
const path = require("path");
const { Address, Customer } = require("@medusajs/medusa");
const setupServer = require("../../../helpers/setup-server");
const { useApi } = require("../../../helpers/use-api");
const { initDb } = require("../../../helpers/use-db");
const { initDb, useDb } = require("../../../helpers/use-db");
const customerSeeder = require("../../helpers/customer-seeder");
@@ -14,9 +13,9 @@ describe("/store/customers", () => {
let medusaProcess;
let dbConnection;
const doAfterEach = async (manager) => {
await manager.query(`DELETE FROM "customer"`);
await manager.query(`DELETE FROM "address"`);
const doAfterEach = async () => {
const db = useDb();
await db.teardown();
};
beforeAll(async () => {
@@ -26,9 +25,8 @@ describe("/store/customers", () => {
});
afterAll(async () => {
dbConnection.close();
await dropDatabase({ databaseName: "medusa-integration" });
const db = useDb();
await db.shutdown();
medusaProcess.kill();
});
@@ -46,8 +44,7 @@ describe("/store/customers", () => {
});
afterEach(async () => {
const manager = dbConnection.manager;
await doAfterEach(manager);
await doAfterEach();
});
it("creates a customer", async () => {
@@ -106,8 +103,7 @@ describe("/store/customers", () => {
});
afterEach(async () => {
const manager = dbConnection.manager;
await doAfterEach(manager);
await doAfterEach();
});
it("updates a customer", async () => {