import {
  describe,
  globalExpect,
  init_dist,
  it
} from "../../chunk-GCCHFONX.mjs";
import {
  Blindpay,
  init_client
} from "../../chunk-ES7RXEM7.mjs";
import "../../chunk-GEDDLCJY.mjs";
import "../../chunk-LK3JPQ6I.mjs";
import "../../chunk-CNNEROQ7.mjs";
import "../../chunk-GNDAATIJ.mjs";
import "../../chunk-VKN2AMCW.mjs";
import "../../chunk-LUDGZPXY.mjs";
import "../../chunk-3CZJEDS5.mjs";
import "../../chunk-UCAW3RTZ.mjs";
import "../../chunk-M6IYYMRW.mjs";
import "../../chunk-HKFAJXJG.mjs";
import "../../chunk-QVOSGLUO.mjs";
import "../../chunk-2DAKB5XK.mjs";
import "../../chunk-QHMIK7U3.mjs";
import "../../chunk-LLWEHHKB.mjs";
import {
  __async,
  __commonJS
} from "../../chunk-OBKEW4AQ.mjs";

// src/resources/api-keys/api-keys.test.ts
var require_api_keys_test = __commonJS({
  "src/resources/api-keys/api-keys.test.ts"(exports) {
    init_dist();
    init_client();
    describe("Api keys", () => {
      afterEach(() => fetchMock.resetMocks());
      const blindpay = new Blindpay("test-key");
      describe("Create api key", () => {
        it("should create an api key", () => __async(null, null, function* () {
          const mockedApiKey = {
            id: "ap_000000000000",
            token: "token"
          };
          fetchMock.mockResponseOnce(JSON.stringify(mockedApiKey), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.apiKeys.create({
            instanceId: "in_000000000000",
            name: "test",
            permission: "full_access"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedApiKey);
        }));
      });
      describe("Get api key", () => {
        it("should get an api key", () => __async(null, null, function* () {
          const mockedApiKey = {
            id: "ap_000000000000",
            token: "token",
            name: "test",
            permission: "full_access",
            ip_whitelist: ["127.0.0.1"],
            unkey_id: "key_123456789",
            last_used_at: "2024-01-01T00:00:00.000Z",
            instance_id: "in_000000000000",
            created_at: "2021-01-01",
            updated_at: "2021-01-01"
          };
          fetchMock.mockResponseOnce(JSON.stringify(mockedApiKey), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.apiKeys.get({
            instanceId: "in_000000000000",
            id: "ap_000000000000"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedApiKey);
        }));
      });
      describe("List api keys", () => {
        it("should list api keys", () => __async(null, null, function* () {
          const mockedApiKeys = [
            {
              id: "ap_000000000000",
              token: "token",
              name: "test",
              permission: "full_access",
              ip_whitelist: ["127.0.0.1"],
              unkey_id: "key_123456789",
              last_used_at: "2024-01-01T00:00:00.000Z",
              instance_id: "in_000000000000",
              created_at: "2021-01-01",
              updated_at: "2021-01-01"
            }
          ];
          fetchMock.mockResponseOnce(JSON.stringify(mockedApiKeys), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.apiKeys.list({
            instanceId: "in_000000000000"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedApiKeys);
        }));
      });
      describe("Delete api key", () => {
        it("should delete an api key", () => __async(null, null, function* () {
          fetchMock.mockResponseOnce(
            JSON.stringify({
              data: null
            }),
            {
              headers: { "Content-Type": "application/json" }
            }
          );
          const { data, error } = yield blindpay.instances.apiKeys.delete({
            instanceId: "in_000000000000",
            id: "ap_000000000000"
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual({
            data: null
          });
        }));
      });
    });
  }
});
export default require_api_keys_test();
