// This file was auto-generated by Fern from our API Definition.

import * as Cohere from "../../src/api/index";
import { CohereClient } from "../../src/Client";
import { mockServerPool } from "../mock-server/MockServerPool";

describe("Datasets", () => {
    test("list (1)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = {
            datasets: [
                {
                    id: "id",
                    name: "name",
                    created_at: "2024-01-15T09:30:00Z",
                    updated_at: "2024-01-15T09:30:00Z",
                    dataset_type: "embed-input",
                    validation_status: "unknown",
                    validation_error: "validation_error",
                    schema: "schema",
                    required_fields: ["required_fields"],
                    preserve_fields: ["preserve_fields"],
                    dataset_parts: [{ id: "id", name: "name" }],
                    validation_warnings: ["validation_warnings"],
                },
            ],
        };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.datasets.list({
            datasetType: "datasetType",
            before: new Date("2024-01-15T09:30:00.000Z"),
            after: new Date("2024-01-15T09:30:00.000Z"),
            limit: 1.1,
            offset: 1.1,
            validationStatus: "unknown",
        });
        expect(response).toEqual({
            datasets: [
                {
                    id: "id",
                    name: "name",
                    createdAt: new Date("2024-01-15T09:30:00.000Z"),
                    updatedAt: new Date("2024-01-15T09:30:00.000Z"),
                    datasetType: "embed-input",
                    validationStatus: "unknown",
                    validationError: "validation_error",
                    schema: "schema",
                    requiredFields: ["required_fields"],
                    preserveFields: ["preserve_fields"],
                    datasetParts: [
                        {
                            id: "id",
                            name: "name",
                        },
                    ],
                    validationWarnings: ["validation_warnings"],
                },
            ],
        });
    });

    test("list (2)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(400).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.BadRequestError);
    });

    test("list (3)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(401).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.UnauthorizedError);
    });

    test("list (4)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(403).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.ForbiddenError);
    });

    test("list (5)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(404).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.NotFoundError);
    });

    test("list (6)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(422).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.UnprocessableEntityError);
    });

    test("list (7)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(429).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.TooManyRequestsError);
    });

    test("list (8)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(498).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.InvalidTokenError);
    });

    test("list (9)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(499).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.ClientClosedRequestError);
    });

    test("list (10)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(500).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.InternalServerError);
    });

    test("list (11)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(501).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.NotImplementedError);
    });

    test("list (12)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(503).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.ServiceUnavailableError);
    });

    test("list (13)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets").respondWith().statusCode(504).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.list();
        }).rejects.toThrow(Cohere.GatewayTimeoutError);
    });

    test("getUsage (1)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { organization_usage: 1000000 };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.datasets.getUsage();
        expect(response).toEqual({
            organizationUsage: 1000000,
        });
    });

    test("getUsage (2)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(400).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.BadRequestError);
    });

    test("getUsage (3)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(401).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.UnauthorizedError);
    });

    test("getUsage (4)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(403).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.ForbiddenError);
    });

    test("getUsage (5)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(404).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.NotFoundError);
    });

    test("getUsage (6)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(422).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.UnprocessableEntityError);
    });

    test("getUsage (7)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(429).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.TooManyRequestsError);
    });

    test("getUsage (8)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(498).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.InvalidTokenError);
    });

    test("getUsage (9)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(499).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.ClientClosedRequestError);
    });

    test("getUsage (10)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(500).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.InternalServerError);
    });

    test("getUsage (11)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(501).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.NotImplementedError);
    });

    test("getUsage (12)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(503).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.ServiceUnavailableError);
    });

    test("getUsage (13)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/usage").respondWith().statusCode(504).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.getUsage();
        }).rejects.toThrow(Cohere.GatewayTimeoutError);
    });

    test("get (1)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = {
            dataset: {
                id: "id",
                name: "name",
                created_at: "2024-01-15T09:30:00Z",
                updated_at: "2024-01-15T09:30:00Z",
                dataset_type: "embed-input",
                validation_status: "unknown",
                validation_error: "validation_error",
                schema: "schema",
                required_fields: ["required_fields"],
                preserve_fields: ["preserve_fields"],
                dataset_parts: [{ id: "id", name: "name" }],
                validation_warnings: ["validation_warnings"],
            },
        };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.datasets.get("id");
        expect(response).toEqual({
            dataset: {
                id: "id",
                name: "name",
                createdAt: new Date("2024-01-15T09:30:00.000Z"),
                updatedAt: new Date("2024-01-15T09:30:00.000Z"),
                datasetType: "embed-input",
                validationStatus: "unknown",
                validationError: "validation_error",
                schema: "schema",
                requiredFields: ["required_fields"],
                preserveFields: ["preserve_fields"],
                datasetParts: [
                    {
                        id: "id",
                        name: "name",
                    },
                ],
                validationWarnings: ["validation_warnings"],
            },
        });
    });

    test("get (2)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(400).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.BadRequestError);
    });

    test("get (3)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.UnauthorizedError);
    });

    test("get (4)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(403).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.ForbiddenError);
    });

    test("get (5)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.NotFoundError);
    });

    test("get (6)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(422).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.UnprocessableEntityError);
    });

    test("get (7)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(429).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.TooManyRequestsError);
    });

    test("get (8)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(498).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.InvalidTokenError);
    });

    test("get (9)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(499).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.ClientClosedRequestError);
    });

    test("get (10)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(500).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.InternalServerError);
    });

    test("get (11)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(501).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.NotImplementedError);
    });

    test("get (12)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(503).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.ServiceUnavailableError);
    });

    test("get (13)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().get("/v1/datasets/id").respondWith().statusCode(504).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.get("id");
        }).rejects.toThrow(Cohere.GatewayTimeoutError);
    });

    test("delete (1)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(200).jsonBody(rawResponseBody).build();

        const response = await client.datasets.delete("id");
        expect(response).toEqual({
            key: "value",
        });
    });

    test("delete (2)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(400).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.BadRequestError);
    });

    test("delete (3)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(401).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.UnauthorizedError);
    });

    test("delete (4)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(403).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.ForbiddenError);
    });

    test("delete (5)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(404).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.NotFoundError);
    });

    test("delete (6)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(422).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.UnprocessableEntityError);
    });

    test("delete (7)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(429).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.TooManyRequestsError);
    });

    test("delete (8)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(498).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.InvalidTokenError);
    });

    test("delete (9)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(499).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.ClientClosedRequestError);
    });

    test("delete (10)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(500).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.InternalServerError);
    });

    test("delete (11)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(501).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.NotImplementedError);
    });

    test("delete (12)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(503).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.ServiceUnavailableError);
    });

    test("delete (13)", async () => {
        const server = mockServerPool.createServer();
        const client = new CohereClient({ token: "test", clientName: "test", environment: server.baseUrl });

        const rawResponseBody = { key: "value" };
        server.mockEndpoint().delete("/v1/datasets/id").respondWith().statusCode(504).jsonBody(rawResponseBody).build();

        await expect(async () => {
            return await client.datasets.delete("id");
        }).rejects.toThrow(Cohere.GatewayTimeoutError);
    });
});
