Skip to content

Commit

Permalink
allow session to be async in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sportdeath committed Feb 6, 2025
1 parent 0a15629 commit 68dcc88
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 224 deletions.
162 changes: 81 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@graffiti-garden/api",
"version": "0.2.8",
"version": "0.2.9",
"description": "The heart of Graffiti",
"types": "./dist/src/index.d.ts",
"module": "./dist/index.mjs",
Expand Down
27 changes: 16 additions & 11 deletions tests/channel-stats.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { it, expect, describe, assert } from "vitest";
import { it, expect, describe, assert, beforeEach } from "vitest";
import type { Graffiti, GraffitiSession } from "@graffiti-garden/api";
import { randomPutObject, randomString } from "./utils";
import { randomString } from "./utils";

export const graffitiChannelStatsTests = (
useGraffiti: () => Pick<
Graffiti,
"channelStats" | "put" | "delete" | "patch"
>,
useSession1: () => GraffitiSession,
useSession2: () => GraffitiSession,
useSession1: () => GraffitiSession | Promise<GraffitiSession>,
useSession2: () => GraffitiSession | Promise<GraffitiSession>,
) => {
describe("channel stats", () => {
it("list channels", async () => {
const graffiti = useGraffiti();
const session = useSession1();
describe("channel stats", { timeout: 20000 }, () => {
let graffiti: ReturnType<typeof useGraffiti>;
let session: GraffitiSession;
let session1: GraffitiSession;
let session2: GraffitiSession;
beforeEach(async () => {
graffiti = useGraffiti();
session1 = await useSession1();
session = session1;
session2 = await useSession2();
});

it("list channels", async () => {
const existingChannels: Map<string, number> = new Map();
const channelIterator1 = graffiti.channelStats(session);
for await (const channel of channelIterator1) {
Expand Down Expand Up @@ -65,9 +73,6 @@ export const graffitiChannelStatsTests = (
});

it("list channels with deleted channel", async () => {
const graffiti = useGraffiti();
const session = useSession1();

const channels = [randomString(), randomString(), randomString()];

// Add an item with two channels
Expand Down
Loading

0 comments on commit 68dcc88

Please sign in to comment.