Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
evadecker committed Dec 2, 2024
1 parent 6f7427b commit cc6796d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions convex/topics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,27 @@ describe("topics", () => {
expect(topics[1].topic).toBe("Adoption");
expect(topics[2].topic).toBe("Costs");
});

it("errors if attempting to delete a topic with faqs", async () => {
const t = convexTest(schema, modules);

// Create a topic first
const topicId = await t.mutation(api.topics.createTopic, {
topic: "Costs",
});

// Create a FAQ
await t.mutation(api.faqs.createFAQ, {
question: "How much does the process cost?",
answer: "It varies.",
topics: [topicId],
});

// Attempt to delete the topic
await expect(
t.mutation(api.topics.deleteTopic, {
topicId,
}),
).rejects.toThrowError("Cannot delete topic with faqs");
});
});

0 comments on commit cc6796d

Please sign in to comment.