Skip to content

Commit

Permalink
Rename utitlity method to find parent entity
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandroboron committed Aug 29, 2024
1 parent 62c6dec commit efdde84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ extension TrackerData {
return nil
}

/// Returns the entity associated with the host. If the entity is owned by a parent entity, it returns the parent entity.
/// Returns the parent of the entity associated with the host if any. If the entity associated with the host doesn't have a parent return the entity. Otherwise, return nil.
/// - Parameter host:
/// - Returns: The entity associated with the host.
public func findParentOrFallback(forHost host: String) -> Entity? {
public func findParentEntityOrFallback(forHost host: String) -> Entity? {
// If the entity associated with the host is owned by a parent company (e.g. Instagram is owned by Facebook) return the parent company.
// If the entity associated with the host is not owned by a parent company return the entity.
// If the are no entities associated with the host return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ final class TrackerDataQueryExtensionTests: XCTestCase {
let tds = try JSONDecoder().decode(TrackerData.self, from: Self.mockTDS)

// WHEN
let result = try XCTUnwrap(tds.findParentOrFallback(forHost: "www.instagram.com"))
let result = try XCTUnwrap(tds.findParentEntityOrFallback(forHost: "www.instagram.com"))

// THEN
XCTAssertEqual(result.displayName, "Facebook")
Expand All @@ -39,7 +39,7 @@ final class TrackerDataQueryExtensionTests: XCTestCase {
let tds = try JSONDecoder().decode(TrackerData.self, from: Self.mockTDS)

// WHEN
let result = try XCTUnwrap(tds.findParentOrFallback(forHost: "www.roku.com"))
let result = try XCTUnwrap(tds.findParentEntityOrFallback(forHost: "www.roku.com"))

// THEN
XCTAssertEqual(result.displayName, "Roku")
Expand All @@ -50,7 +50,7 @@ final class TrackerDataQueryExtensionTests: XCTestCase {
let tds = try JSONDecoder().decode(TrackerData.self, from: Self.mockTDS)

// WHEN
let result = tds.findParentOrFallback(forHost: "www.test.com")
let result = tds.findParentEntityOrFallback(forHost: "www.test.com")

// THEN
XCTAssertNil(result)
Expand Down

0 comments on commit efdde84

Please sign in to comment.