import { graphDataTestRunner } from "@receptron/test_utils";
import { fetchAgent } from "../src/index";
import { propertyFilterAgent, copyAgent } from "@graphai/vanilla";

import { graphDataFetch, graphDataPost } from "./graphData";

import test from "node:test";
import assert from "node:assert";

test("test fetch", async () => {
  const result = await graphDataTestRunner(__dirname, __filename, graphDataFetch, { fetchAgent, copyAgent }, () => {}, false);
  assert.deepStrictEqual(result, { success: { result: true } });
});

test("test fetch post", async () => {
  const result = await graphDataTestRunner(__dirname, __filename, graphDataPost, { fetchAgent, copyAgent, propertyFilterAgent }, () => {}, false);
  assert.deepStrictEqual(result, {
    error: {
      message: "HTTP error: 429",
      status: 429,
    },
  });
});
