Skip to content

Commit ceabece

Browse files
author
Evan Greer
committed
updates complex criteria 3 tests
1 parent c7f6f43 commit ceabece

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

tests/unit-tests/CombinationComplexCriteria.swift

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -506,41 +506,72 @@ final class CombinationComplexCriteria: XCTestCase {
506506
}
507507
}
508508
]
509+
},
510+
{
511+
"combinator": "Not",
512+
"searchQueries": [
513+
{
514+
"dataType": "purchase",
515+
"searchCombo": {
516+
"combinator": "And",
517+
"searchQueries": [
518+
{
519+
"dataType": "purchase",
520+
"field": "total",
521+
"comparatorType": "LessThanOrEqualTo",
522+
"value": "10",
523+
"fieldType": "double"
524+
}
525+
]
526+
}
527+
},
528+
{
529+
"dataType": "purchase",
530+
"searchCombo": {
531+
"combinator": "And",
532+
"searchQueries": [
533+
{
534+
"dataType": "purchase",
535+
"field": "shoppingCartItems.quantity",
536+
"comparatorType": "LessThanOrEqualTo",
537+
"value": "34",
538+
"fieldType": "long"
539+
}
540+
]
541+
}
542+
}
543+
]
509544
}
510545
]
511546
}
512547
}
513548
]
514-
}
549+
}
515550
"""
516551

517552
func testComplexCriteria3Success() {
518553
let eventItems: [[AnyHashable: Any]] = [
519-
["dataType":"user",
520-
"dataFields": ["firstName": "xcode", "lastName":"ssr"]
521-
],
522-
["dataType": "customEvent",
523-
"eventName": "animal-found",
524-
"dataFields": ["vaccinated":true,
525-
"count":10]
554+
[
555+
"dataType":"purchase",
556+
"createdAt": 1699246745093,
557+
"items": [["id": "12", "name": "coffee", "price": 100, "quantity": 2]]
526558
]
527559
]
528560

529-
530561
let expectedCriteriaId = "292"
531562
let matchedCriteriaId = CriteriaCompletionChecker(anonymousCriteria: data(from: mockDataComplexCriteria3)!, anonymousEvents: eventItems).getMatchedCriteria()
532563
XCTAssertEqual(matchedCriteriaId, expectedCriteriaId)
533564
}
534565

535566
func testComplexCriteria3Fail() {
536567
let eventItems: [[AnyHashable: Any]] = [
568+
[
569+
"dataType":"purchase",
570+
"createdAt": 1699246745093,
571+
"items": [["id": "12", "name": "coffee", "price": 100, "quantity": 2]]
572+
],
537573
["dataType":"user",
538574
"dataFields": ["firstName": "Alex", "lastName":"Aris"]
539-
],
540-
["dataType": "customEvent",
541-
"eventName": "animal-found",
542-
"dataFields": ["vaccinated":false,
543-
"count":4]
544575
]
545576
]
546577
let matchedCriteriaId = CriteriaCompletionChecker(anonymousCriteria: data(from: mockDataComplexCriteria3)!, anonymousEvents: eventItems).getMatchedCriteria()

0 commit comments

Comments
 (0)