openpanel/packages/medusa/test/utils/mapOperator.spec.ts
Stefan Pejcic 09f9f9502d packages
2024-11-07 19:03:37 +01:00

33 lines
798 B
TypeScript

import type { CrudOperators } from "@refinedev/core";
import { mapOperator } from "../../src/utils";
describe("mapOperator", () => {
it("should map 'eq' operator to an empty string", () => {
const operator = "eq";
const result = mapOperator(operator);
expect(result).toEqual("");
});
it("should throw an error for unsupported operators", () => {
const unsupportedOperators: CrudOperators[] = [
"ne",
"gt",
"gte",
"lt",
"lte",
"contains",
"ncontains",
"containss",
"ncontainss",
"null",
"nnull",
];
unsupportedOperators.forEach((operator) => {
expect(() => mapOperator(operator)).toThrow(
`Operator ${operator} is not supported for the Medusa data provider`,
);
});
});
});