mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { CrudOperators } from "@refinedev/core";
|
|
import { mapOperator } from "../../src/utils";
|
|
|
|
describe("mapOperator", () => {
|
|
it("should return correct mapping for given operator", () => {
|
|
const operatorMappings: Record<CrudOperators, string> = {
|
|
ne: "_ne",
|
|
gte: "_gte",
|
|
lte: "_lte",
|
|
contains: "_like",
|
|
eq: "",
|
|
and: "",
|
|
between: "",
|
|
containss: "",
|
|
endswith: "",
|
|
endswiths: "",
|
|
gt: "",
|
|
in: "",
|
|
lt: "",
|
|
ncontains: "",
|
|
ncontainss: "",
|
|
nendswith: "",
|
|
nendswiths: "",
|
|
nnull: "",
|
|
nin: "",
|
|
nbetween: "",
|
|
nstartswith: "",
|
|
nstartswiths: "",
|
|
null: "",
|
|
or: "",
|
|
startswith: "",
|
|
startswiths: "",
|
|
};
|
|
|
|
for (const operator in operatorMappings) {
|
|
const expectedResult = operatorMappings[operator as CrudOperators];
|
|
expect(mapOperator(operator as CrudOperators)).toEqual(
|
|
expectedResult,
|
|
);
|
|
}
|
|
});
|
|
|
|
it.each(["unsupported", "", undefined, null])(
|
|
"should return empty string for %s operator ",
|
|
(operator) => {
|
|
expect(mapOperator(operator as CrudOperators)).toEqual("");
|
|
},
|
|
);
|
|
});
|