chore: Reduce test boilerplate (#4300)
* chore: Reduce test boilerplate * mo
This commit is contained in:
@@ -1,18 +1,11 @@
|
||||
import { Backlink } from "@server/models";
|
||||
import { buildDocument } from "@server/test/factories";
|
||||
import { getTestDatabase } from "@server/test/support";
|
||||
import { setupTestDatabase } from "@server/test/support";
|
||||
import BacklinksProcessor from "./BacklinksProcessor";
|
||||
|
||||
const ip = "127.0.0.1";
|
||||
|
||||
const db = getTestDatabase();
|
||||
|
||||
afterAll(db.disconnect);
|
||||
|
||||
beforeEach(async () => {
|
||||
await db.flush();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
setupTestDatabase();
|
||||
|
||||
describe("documents.publish", () => {
|
||||
test("should create new backlink records", async () => {
|
||||
|
||||
@@ -12,18 +12,15 @@ import {
|
||||
buildCollection,
|
||||
buildUser,
|
||||
} from "@server/test/factories";
|
||||
import { getTestDatabase } from "@server/test/support";
|
||||
import { setupTestDatabase } from "@server/test/support";
|
||||
import NotificationsProcessor from "./NotificationsProcessor";
|
||||
|
||||
jest.mock("@server/emails/templates/DocumentNotificationEmail");
|
||||
const ip = "127.0.0.1";
|
||||
|
||||
const db = getTestDatabase();
|
||||
|
||||
afterAll(db.disconnect);
|
||||
setupTestDatabase();
|
||||
|
||||
beforeEach(async () => {
|
||||
await db.flush();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
|
||||
@@ -1,18 +1,11 @@
|
||||
import { Revision } from "@server/models";
|
||||
import { buildDocument } from "@server/test/factories";
|
||||
import { getTestDatabase } from "@server/test/support";
|
||||
import { setupTestDatabase } from "@server/test/support";
|
||||
import RevisionsProcessor from "./RevisionsProcessor";
|
||||
|
||||
const ip = "127.0.0.1";
|
||||
|
||||
const db = getTestDatabase();
|
||||
|
||||
afterAll(db.disconnect);
|
||||
|
||||
beforeEach(async () => {
|
||||
await db.flush();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
setupTestDatabase();
|
||||
|
||||
describe("documents.update.debounced", () => {
|
||||
test("should create a revision", async () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { buildUser, buildWebhookSubscription } from "@server/test/factories";
|
||||
import { getTestDatabase } from "@server/test/support";
|
||||
import { setupTestDatabase } from "@server/test/support";
|
||||
import { UserEvent } from "@server/types";
|
||||
import DeliverWebhookTask from "../tasks/DeliverWebhookTask";
|
||||
import WebhookProcessor from "./WebhookProcessor";
|
||||
@@ -7,12 +7,9 @@ import WebhookProcessor from "./WebhookProcessor";
|
||||
jest.mock("@server/queues/tasks/DeliverWebhookTask");
|
||||
const ip = "127.0.0.1";
|
||||
|
||||
const db = getTestDatabase();
|
||||
|
||||
afterAll(db.disconnect);
|
||||
setupTestDatabase();
|
||||
|
||||
beforeEach(async () => {
|
||||
await db.flush();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user