import { a1 as g, L as l, e2 as p, T as x, hF as h, _ as s, hG as w } from "./56c67d3b.js";
import "react";
import "react-dom";
test("test column", () => {
  const t = {
    title: "name"
    // editable: true, // TODO: change to boolean
  };
  let a = new g({
    value: t
  });
  a = l(a);
  const e = a.getView();
  expect(e.title).toEqual(t.title);
});
test("test column render", () => {
  const t = {
    render: {
      compType: "text",
      comp: {
        text: "{{currentRow.id}}"
      }
    }
    // editable: true, // TODO: change to boolean
  };
  let a = new g({
    value: t
  });
  a = l(a);
  const e = a.getView();
  expect(e.render({
    currentCell: null,
    currentIndex: null,
    currentRow: {
      id: "hello"
    },
    currentOriginalIndex: null
  }, "0").getView().view({}).props.normalView).toEqual("hello");
});
test("test table", async () => {
  const t = {
    data: JSON.stringify([{
      a: 1
    }]),
    columns: [{
      dataIndex: "a",
      hide: !0
    }, {
      title: "custom",
      dataIndex: "",
      isCustom: !0
    }]
  }, a = {
    query1: p({
      data: [{
        q: 1
      }]
    }),
    query2: p({
      data: [{
        q2: 2
      }]
    })
  };
  let e = new x({
    dispatch: (c) => {
      e = l(e.reduce(c), a);
    },
    value: t
  });
  e = l(e);
  let o = e.children.columns.getView();
  expect(o.length).toEqual(2), e = l(e.reduce(e.changeChildAction("data", '[{"a":1, "c":2, "d":3}]'))), await new Promise((c) => setTimeout(c, 20)), o = e.children.columns.getView(), expect(o.length).toEqual(4), expect(o[0].getView().dataIndex).toEqual("a"), expect(o[0].getView().hide).toBe(!0), expect(o[1].getView().title).toEqual("custom"), expect(o[2].getView().title).toEqual("c"), expect(o[3].getView().title).toEqual("d");
}, 1e3);
test("test mock table render", () => {
  let t = new h({});
  t = l(t);
});
test("test table data transform", () => {
  function t(n, r) {
    const i = r.exposingValues.displayData, {
      data: d
    } = r.getProps(), m = r.filterData;
    return expect(d.length).toEqual(3), expect(i.length).toEqual(n), expect(i.map((u) => s.omit(u, "custom"))).toEqual(s.map(m, (u) => s.omit(u, w))), {
      transformedData: m,
      data: d,
      displayData: i
    };
  }
  const a = {
    data: JSON.stringify([{
      id: 1,
      name: "gg"
    }, {
      id: 5,
      name: "gg2"
    }, {
      id: 3,
      name: "jjj"
    }]),
    columns: [{
      dataIndex: "id",
      isCustom: !1,
      sortable: !0,
      render: {
        compType: "text",
        comp: {
          text: "{{currentCell}}"
        }
      }
    }, {
      dataIndex: "name",
      isCustom: !1,
      render: {
        compType: "text",
        comp: {
          text: "{{currentCell}}"
        }
      }
    }, {
      title: "custom",
      dataIndex: "ealekfg",
      isCustom: !0,
      render: {
        compType: "image",
        comp: {
          src: "{{currentRow.id}}"
        }
      }
    }]
  };
  let e = new x({
    dispatch: (n) => {
      e = l(e.reduce(n));
    },
    value: a
  });
  e = l(e), e = l(e.reduce(e.changeChildAction("sort", [{
    column: "id",
    desc: !0
  }])));
  let {
    transformedData: o,
    data: c,
    displayData: f
  } = t(3, e);
  expect(o.map((n) => n.id)).toEqual([5, 3, 1]), e = l(e.reduce(e.changeChildAction("toolbar", {
    searchText: "gg"
  }))), t(2, e), e = l(e.reduce(e.changeChildAction("toolbar", {
    showFilter: !0,
    filter: {
      stackType: "and",
      filters: [{
        columnKey: "id",
        filterValue: "4",
        operator: "gt"
      }, {
        columnKey: "id",
        filterValue: "5",
        operator: "lte"
      }]
    }
  }))), t(1, e);
});
