import {
  describe,
  globalExpect,
  init_dist,
  it
} from "../../chunk-D6N3USMR.mjs";
import {
  BlindPay,
  init_client
} from "../../chunk-VWWGGMMT.mjs";
import "../../chunk-FG25JHDX.mjs";
import "../../chunk-KMU6V4LW.mjs";
import "../../chunk-QGNLMN6Z.mjs";
import "../../chunk-ISHZTBAN.mjs";
import "../../chunk-UDRMLZWT.mjs";
import "../../chunk-LEPGLH7Q.mjs";
import "../../chunk-UC57SCKQ.mjs";
import "../../chunk-E7M4CJKR.mjs";
import "../../chunk-F5Z45GCA.mjs";
import "../../chunk-TBTA7A2P.mjs";
import "../../chunk-YIZJM2GU.mjs";
import "../../chunk-Z6EYX4D3.mjs";
import "../../chunk-ALHMJWQN.mjs";
import "../../chunk-B5T7AQLH.mjs";
import "../../chunk-RC5NN5UF.mjs";
import "../../chunk-VGU72ZNI.mjs";
import "../../chunk-LRHWT4JU.mjs";
import "../../chunk-WE73MTQL.mjs";
import "../../chunk-UOAM7SX3.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({ apiKey: "test-key", instanceId: "in_000000000000" });
      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({
            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("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();
          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("ap_000000000000");
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual({
            data: null
          });
        }));
      });
    });
  }
});
export default require_api_keys_test();
