import { cT as t, hK as s, L as a, a4 as o } from "./56c67d3b.js";
import "react";
import "react-dom";
jest.mock("lowcoder-design/src/components/GlobalInstances", () => ({
  __esModule: !0,
  // this property makes it work
  default: "mockedDefaultExport",
  messageInstance: {
    error: jest.fn(),
    success: jest.fn()
  }
}));
const c = {
  value: {
    showSuccess: !0,
    success: {
      text: "success"
    },
    showFail: !0,
    fail: [{
      text: "{{ data + 1 }}",
      condition: "{{ data + 1 === 2 }}"
    }, {
      text: "{{ data }}",
      condition: "{{ data === 3 }}"
    }],
    duration: ""
  }
};
beforeAll(() => {
  jest.spyOn(t, "error"), jest.spyOn(t, "success");
});
test("test custom fail", () => {
  let e = new s(c);
  e = a(e), e.getView()("", "automatic", {
    data: 1,
    success: !1
  }), expect(t.error).toHaveBeenCalledWith("2", 3);
});
test("test system fail", () => {
  let e = new s(c);
  e = a(e), e.getView()("", "automatic", {
    data: 4,
    success: !1
  }), expect(t.error).toHaveBeenCalledWith(o("query.failMessageWithName", {
    name: "",
    result: "{}"
  }), 3);
});
test("test custom success", () => {
  let e = new s(c);
  e = a(e), e.getView()("", "automatic", {
    data: 4,
    success: !0
  }), expect(t.success).toHaveBeenCalledTimes(0), e.getView()("", "manual", {
    data: 4,
    success: !1
  }), expect(t.success).toHaveBeenCalledTimes(0), e.getView()("", "manual", {
    data: 1,
    success: !0
  }), expect(t.success).toHaveBeenCalledTimes(0), expect(t.error).toHaveBeenCalled(), e.getView()("", "manual", {
    data: 4,
    success: !0
  }), expect(t.success).toHaveBeenCalledWith("success", 3);
});
test("test system success", () => {
  let e = new s({
    value: {
      showSuccess: !0,
      success: {
        text: ""
      },
      showFail: !0,
      fail: [{
        text: "{{ data }}",
        condition: "{{ data === 2 }}"
      }, {
        text: "{{ data }}",
        condition: "{{ data === 3 }}"
      }],
      duration: ""
    }
  });
  e = a(e), e.getView()("", "manual", {
    data: 4,
    success: !0
  }), expect(t.success).toHaveBeenCalledWith(o("query.successMessageWithName", {
    name: ""
  }), 3);
});
test("test duration", () => {
  let e = new s({
    value: {
      ...c.value,
      duration: "3s"
    }
  });
  e = a(e), e.getView()("", "automatic", {
    data: 1,
    success: !1
  }), expect(t.error).toHaveBeenNthCalledWith(1, "2", 3), e = new s({
    value: {
      ...c.value,
      duration: "1000ms"
    }
  }), e = a(e), e.getView()("", "automatic", {
    data: 1,
    success: !1
  }), expect(t.error).toHaveBeenNthCalledWith(2, "2", 1), e = new s({
    value: {
      ...c.value,
      duration: "{{2*2}}"
    }
  }), e = a(e), e.getView()("", "automatic", {
    data: 1,
    success: !1
  }), expect(t.error).toHaveBeenNthCalledWith(3, "2", 4);
});
