import {
  afterEach,
  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/webhooks/webhooks.test.ts
var require_webhooks_test = __commonJS({
  "src/resources/webhooks/webhooks.test.ts"(exports) {
    init_dist();
    init_client();
    describe("Webhooks", () => {
      afterEach(() => fetchMock.resetMocks());
      const blindpay = new BlindPay({ apiKey: "test-key", instanceId: "in_000000000000" });
      describe("Create webhook endpoint", () => {
        it("should create a webhook endpoint", () => __async(null, null, function* () {
          const mockedWebhookEndpoint = {
            id: "we_000000000000"
          };
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookEndpoint), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.create({
            url: "https://example.com/webhook",
            events: ["receiver.new"]
          });
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookEndpoint);
        }));
      });
      describe("List webhook endpoints", () => {
        it("should list webhook endpoints", () => __async(null, null, function* () {
          const mockedWebhookEndpoints = [
            {
              id: "we_000000000000",
              url: "https://example.com/webhook",
              events: ["receiver.new"],
              last_event_at: "2024-01-01T00:00:00.000Z",
              instance_id: "in_000000000000",
              created_at: "2021-01-01T00:00:00Z",
              updated_at: "2021-01-01T00:00:00Z"
            }
          ];
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookEndpoints), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.list();
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookEndpoints);
        }));
      });
      describe("Delete webhook endpoint", () => {
        it("should delete a webhook endpoint", () => __async(null, null, function* () {
          const mockedResponse = { data: null };
          fetchMock.mockResponseOnce(JSON.stringify(mockedResponse), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.delete("we_000000000000");
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedResponse);
        }));
      });
      describe("Get webhook endpoint secret", () => {
        it("should get webhook endpoint secret", () => __async(null, null, function* () {
          const mockedWebhookSecret = { key: "whsec_000000000000" };
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookSecret), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.getSecret("we_000000000000");
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookSecret);
        }));
      });
      describe("Get webhook portal access url", () => {
        it("should get webhook portal access url", () => __async(null, null, function* () {
          const mockedWebhookUrl = { url: "https://example.com/webhook" };
          fetchMock.mockResponseOnce(JSON.stringify(mockedWebhookUrl), {
            headers: { "Content-Type": "application/json" }
          });
          const { data, error } = yield blindpay.instances.webhookEndpoints.getPortalAccessUrl();
          globalExpect(error).toBeNull();
          globalExpect(data).toEqual(mockedWebhookUrl);
        }));
      });
    });
  }
});
export default require_webhooks_test();
