From 91b07b62305f11c8b8ed74fe3522d7eb9ec59632 Mon Sep 17 00:00:00 2001 From: Zita Szupera Date: Mon, 6 Nov 2023 16:47:27 +0100 Subject: [PATCH] Update block list name --- __tests__/block-lists.test.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/__tests__/block-lists.test.ts b/__tests__/block-lists.test.ts index a2873a5..7311a30 100644 --- a/__tests__/block-lists.test.ts +++ b/__tests__/block-lists.test.ts @@ -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!; @@ -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(() => { @@ -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(); });