Skip to content

Commit

Permalink
test(util): await insertMany instead of counting items
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Dec 24, 2023
1 parent 1931bc6 commit 09303f8
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/util/tests/unit/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { ObjectId } from "mongodb";

test.before(async (t) => {
const items = await testDatabase("items");
items.insertMany([{ name: "foo" }, { name: "bar" }, { name: "baz" }]);
items.count();
await items.insertMany([{ name: "foo" }, { name: "bar" }, { name: "baz" }]);
t.context.items = items;
});

test.serial("Gets pagination cursor", async (t) => {
test("Gets pagination cursor", async (t) => {
const result = await getCursor(t.context.items, false, false, 3);

// baz, bar, foo
Expand All @@ -21,7 +20,7 @@ test.serial("Gets pagination cursor", async (t) => {
t.false(result.hasPrev);
});

test.serial("Gets pagination cursor after ID", async (t) => {
test("Gets pagination cursor after ID", async (t) => {
const after = await t.context.items.findOne({ name: "baz" });
const result = await getCursor(t.context.items, after._id);

Expand All @@ -31,7 +30,7 @@ test.serial("Gets pagination cursor after ID", async (t) => {
t.true(result.hasPrev);
});

test.serial("Gets pagination cursor after and before IDs", async (t) => {
test("Gets pagination cursor after and before IDs", async (t) => {
const after = await t.context.items.findOne({ name: "baz" });
const before = await t.context.items.findOne({ name: "foo" });
const result = await getCursor(t.context.items, after._id, before._id, 1);
Expand Down

0 comments on commit 09303f8

Please sign in to comment.