More tests
This commit is contained in:
parent
bfdead820c
commit
f73b7d4824
|
@ -23,6 +23,7 @@ import {
|
||||||
EmptyFilterOption,
|
EmptyFilterOption,
|
||||||
FieldType,
|
FieldType,
|
||||||
JsonFieldSubType,
|
JsonFieldSubType,
|
||||||
|
LogicalOperator,
|
||||||
RelationshipType,
|
RelationshipType,
|
||||||
Row,
|
Row,
|
||||||
RowSearchParams,
|
RowSearchParams,
|
||||||
|
@ -2331,7 +2332,9 @@ describe.each([
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("logical filters", () => {
|
describe("logical filters", () => {
|
||||||
describe("just $ands", () => {
|
const logicalOperators = [LogicalOperator.AND, LogicalOperator.OR]
|
||||||
|
|
||||||
|
describe("$and", () => {
|
||||||
it("should allow single conditions", async () => {
|
it("should allow single conditions", async () => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$and: {
|
$and: {
|
||||||
|
@ -2359,9 +2362,11 @@ describe.each([
|
||||||
}).toContainExactly([])
|
}).toContainExactly([])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow nested ands with single conditions", async () => {
|
it.each([logicalOperators])(
|
||||||
|
"should allow nested ands with single conditions (with %s as root)",
|
||||||
|
async rootOperator => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$and: {
|
[rootOperator]: {
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
$and: {
|
$and: {
|
||||||
|
@ -2377,11 +2382,14 @@ describe.each([
|
||||||
}).toContainExactly([
|
}).toContainExactly([
|
||||||
{ name: "foo", productCat: [{ _id: productCatRows[0]._id }] },
|
{ name: "foo", productCat: [{ _id: productCatRows[0]._id }] },
|
||||||
])
|
])
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
it("should allow nested ands with exclusive conditions", async () => {
|
it.each([logicalOperators])(
|
||||||
|
"should allow nested ands with exclusive conditions (with %s as root)",
|
||||||
|
async rootOperator => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$and: {
|
[rootOperator]: {
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
$and: {
|
$and: {
|
||||||
|
@ -2396,11 +2404,14 @@ describe.each([
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).toContainExactly([])
|
}).toContainExactly([])
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
it("should allow nested ands with multiple conditions", async () => {
|
it.each([logicalOperators])(
|
||||||
|
"should allow nested ands with multiple conditions (with %s as root)",
|
||||||
|
async rootOperator => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$and: {
|
[rootOperator]: {
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
$and: {
|
$and: {
|
||||||
|
@ -2415,10 +2426,11 @@ describe.each([
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).toContainExactly([])
|
}).toContainExactly([])
|
||||||
})
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("just $ors", () => {
|
describe("$ors", () => {
|
||||||
it("should allow single conditions", async () => {
|
it("should allow single conditions", async () => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$or: {
|
$or: {
|
||||||
|
@ -2450,9 +2462,11 @@ describe.each([
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should allow nested ors with single conditions", async () => {
|
it.each([logicalOperators])(
|
||||||
|
"should allow nested ors with single conditions (with %s as root)",
|
||||||
|
async rootOperator => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$or: {
|
[rootOperator]: {
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
$or: {
|
$or: {
|
||||||
|
@ -2468,11 +2482,14 @@ describe.each([
|
||||||
}).toContainExactly([
|
}).toContainExactly([
|
||||||
{ name: "foo", productCat: [{ _id: productCatRows[0]._id }] },
|
{ name: "foo", productCat: [{ _id: productCatRows[0]._id }] },
|
||||||
])
|
])
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
it("should allow nested ors with exclusive conditions", async () => {
|
it.each([logicalOperators])(
|
||||||
|
"should allow nested ors with exclusive conditions (with %s as root)",
|
||||||
|
async rootOperator => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$or: {
|
[rootOperator]: {
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
$or: {
|
$or: {
|
||||||
|
@ -2491,11 +2508,14 @@ describe.each([
|
||||||
{ name: "bar", productCat: [{ _id: productCatRows[1]._id }] },
|
{ name: "bar", productCat: [{ _id: productCatRows[1]._id }] },
|
||||||
// { name: "baz", productCat: undefined }, // TODO
|
// { name: "baz", productCat: undefined }, // TODO
|
||||||
])
|
])
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
it("should allow nested ors with multiple conditions", async () => {
|
it.each([logicalOperators])(
|
||||||
|
"should allow nested ors with multiple conditions (with %s as root)",
|
||||||
|
async rootOperator => {
|
||||||
await expectQuery({
|
await expectQuery({
|
||||||
$or: {
|
[rootOperator]: {
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
$or: {
|
$or: {
|
||||||
|
@ -2514,7 +2534,8 @@ describe.each([
|
||||||
{ name: "bar", productCat: [{ _id: productCatRows[1]._id }] },
|
{ name: "bar", productCat: [{ _id: productCatRows[1]._id }] },
|
||||||
// { name: "baz", productCat: undefined }, // TODO
|
// { name: "baz", productCat: undefined }, // TODO
|
||||||
])
|
])
|
||||||
})
|
}
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue