-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: updating
orderedFacets
of the DynamicFacetListInteractor
ign…
…ores `disjunctiveFacets` (#258)
- Loading branch information
1 parent
5981de8
commit abcc825
Showing
3 changed files
with
74 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
Tests/InstantSearchCoreTests/Unit/DynamicFacets/DynamicFacetListInteractorTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// DynamicFacetListInteractorTests.swift | ||
// | ||
// | ||
// Created by Vladislav Fitc on 12/10/2022. | ||
// | ||
|
||
import Foundation | ||
@testable import InstantSearchCore | ||
import XCTest | ||
|
||
class DynamicFacetListInteractorTests: XCTestCase { | ||
|
||
func testDisjunctiveFacetsPropagation() { | ||
let interactor = DynamicFacetListInteractor() | ||
|
||
func facets(of raw: (String, Int)...) -> [Facet] { | ||
raw.map { Facet(value: $0.0, count: $0.1) } | ||
} | ||
|
||
var response = SearchResponse() | ||
|
||
response.facets = [ | ||
"size": facets(of: ("s", 10)), | ||
"brand": facets(of: ("samsung", 5), ("sony", 4), ("philips", 12)), | ||
] | ||
response.disjunctiveFacets = [ | ||
"size": facets(of: ("s", 10), ("m", 20), ("l", 30), ("xl", 40)), | ||
"color": facets(of: ("red", 5), ("green", 10), ("blue", 15)) | ||
] | ||
response.renderingContent = try! RenderingContent(json: [ | ||
"facetOrdering": [ | ||
"facets": [ | ||
"order": [ | ||
"color", | ||
"size", | ||
"brand", | ||
], | ||
], | ||
], | ||
]) | ||
|
||
interactor.update(with: response) | ||
|
||
XCTAssertEqual(interactor.orderedFacets.count, 3) | ||
XCTAssertTrue(interactor.orderedFacets.contains(AttributedFacets(attribute: "size", | ||
facets: facets(of: ("s", 10), ("m", 20), ("l", 30), ("xl", 40))))) | ||
XCTAssertTrue(interactor.orderedFacets.contains(AttributedFacets(attribute: "brand", | ||
facets: facets(of: ("samsung", 5), ("sony", 4), ("philips", 12))))) | ||
XCTAssertTrue(interactor.orderedFacets.contains(AttributedFacets(attribute: "color", | ||
facets: facets(of: ("red", 5), ("green", 10), ("blue", 15))))) | ||
|
||
} | ||
|
||
} |