Skip to content

Commit 79dc65d

Browse files
committed
Fix tree helper tests by awaiting DB collections initialization
1 parent afb60cd commit 79dc65d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/lib/utils/tree/treeHelpers.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { collections } from "$lib/server/database";
1+
import { getCollectionsEarly } from "$lib/server/database";
22
import { ObjectId } from "mongodb";
33
import { describe, expect, it } from "vitest";
44

55
// function used to insert conversations used for testing
6+
const getConversations = async () => (await getCollectionsEarly()).conversations;
67

78
export const insertLegacyConversation = async () => {
8-
const res = await collections.conversations.insertOne({
9+
const conversations = await getConversations();
10+
const res = await conversations.insertOne({
911
_id: new ObjectId(),
1012
createdAt: new Date(),
1113
updatedAt: new Date(),
@@ -39,7 +41,8 @@ export const insertLegacyConversation = async () => {
3941
};
4042

4143
export const insertLinearBranchConversation = async () => {
42-
const res = await collections.conversations.insertOne({
44+
const conversations = await getConversations();
45+
const res = await conversations.insertOne({
4346
_id: new ObjectId(),
4447
createdAt: new Date(),
4548
updatedAt: new Date(),
@@ -82,7 +85,8 @@ export const insertLinearBranchConversation = async () => {
8285
};
8386

8487
export const insertSideBranchesConversation = async () => {
85-
const res = await collections.conversations.insertOne({
88+
const conversations = await getConversations();
89+
const res = await conversations.insertOne({
8690
_id: new ObjectId(),
8791
createdAt: new Date(),
8892
updatedAt: new Date(),

0 commit comments

Comments
 (0)