Skip to content

Commit

Permalink
test: correctly type and test getVideoHeatmap (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-online committed May 8, 2024
1 parent dedd5b6 commit c9536fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,9 @@ export namespace BunnyCdnStream {
engagementScore: number;
}

export type VideoHeatmapResponse = Record<string, unknown>;
export type VideoHeatmapResponse = {
heatmap: Record<string, string | number>;
};

export interface ListVideosResponse {
totalItems: number;
Expand Down
15 changes: 14 additions & 1 deletion tests/Bunny.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createReadStream, readFileSync } from "node:fs";
import { resolve } from "node:path";
import { setTimeout } from "node:timers/promises";
import { config } from "dotenv";
import { afterAll, beforeAll, describe, expect, test } from "vitest";
import { BunnyCdnStream, BunnyCdnStreamVideo } from "../src";
Expand Down Expand Up @@ -118,7 +119,13 @@ describe("BunnyCdnStream", () => {
{ retry: 3 },
async () => {
const videos = await stream.listVideos();
expect(videos.items).toHaveLength(1);
try {
expect(videos.items).toHaveLength(1);
} catch (e) {
await setTimeout(1000);

throw e;
}
},
);

Expand Down Expand Up @@ -224,6 +231,12 @@ describe("BunnyCdnStream", () => {
});
});

test("GIVEN library w/ encoded video THEN can get heatmap", async () => {
const res = await stream.getVideoHeatmap(videoGuid);

expect(res).toEqual({ heatmap: {} });
});

test("GIVEN library w/ encoded video THEN can update", async () => {
await stream.updateVideo(videoGuid, { title: "updated" });
const vid = await stream.getVideo(videoGuid);
Expand Down

0 comments on commit c9536fb

Please sign in to comment.