Skip to content

Commit

Permalink
Update block list name
Browse files Browse the repository at this point in the history
  • Loading branch information
szuperaz committed Nov 6, 2023
1 parent 89281dc commit 91b07b6
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions __tests__/block-lists.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "dotenv/config";
import { beforeAll, beforeEach, describe, expect, it } from "vitest";
import { BlockList, StreamClient } from "../";
import { v4 as uuidv4 } from "uuid";

const apiKey = process.env.STREAM_API_KEY!;
const secret = process.env.STREAM_SECRET!;
Expand All @@ -11,9 +12,9 @@ describe("block lists CRUD API", () => {

beforeEach(() => {
blockList = {
name: 'F1',
words: ['Ricciardo should retire']
}
name: "F1" + uuidv4(),
words: ["Ricciardo should retire"],
};
});

beforeAll(() => {
Expand All @@ -29,25 +30,35 @@ describe("block lists CRUD API", () => {
it("list", async () => {
const listResponse = await client.chat.listBlockLists();

expect(listResponse.blocklists.find(b => b.name === blockList.name)).toBeDefined();
expect(
listResponse.blocklists.find((b) => b.name === blockList.name)
).toBeDefined();

const getResponse = await client.chat.getBlockList({
name: blockList.name,
});

const getResponse = await client.chat.getBlockList({name: blockList.name});

expect(getResponse.blocklist?.name).toBe(blockList.name);
});

it("update", async () => {
const response = await client.chat.updateBlockList(blockList.name, {words: [...blockList.words, 'R1cciardo should retire']});
const response = await client.chat.updateBlockList(blockList.name, {
words: [...blockList.words, "R1cciardo should retire"],
});

expect(response).toBeDefined();

const updatedBlockList = await client.chat.getBlockList({name: blockList.name});
const updatedBlockList = await client.chat.getBlockList({
name: blockList.name,
});

expect(updatedBlockList.blocklist?.words.length).toBe(2);
});

it("delete", async () => {
const response = await client.chat.deleteBlockList({name: blockList.name});
const response = await client.chat.deleteBlockList({
name: blockList.name,
});

expect(response).toBeDefined();
});
Expand Down

0 comments on commit 91b07b6

Please sign in to comment.