Skip to content

Commit

Permalink
Remove loop from test
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-el committed Sep 28, 2023
1 parent fd93a24 commit e80ec11
Showing 1 changed file with 31 additions and 36 deletions.
67 changes: 31 additions & 36 deletions Tests/TestLinkDecorator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,42 +51,37 @@ class TestLinkDecorator: XCTestCase {
let reason = "reason"
let reasonb64 = reason.toBase64()

let testCases = [
// All false
(
config: CrossDeviceParameterConfiguration(sessionId: false, sourceId: false),
expected: "https://example.com?_sp=\(userId).\(epoch)"
)
,
// Default
(
config: CrossDeviceParameterConfiguration(),
expected: "https://example.com?_sp=\(userId).\(epoch).\(sessionId)..\(appId)"
),
(
config: CrossDeviceParameterConfiguration(subjectUserId: true),
expected: "https://example.com?_sp=\(userId).\(epoch).\(sessionId).\(subjectUserId).\(appId)"
),
(
config: CrossDeviceParameterConfiguration(subjectUserId: true, sourcePlatform: true),
expected: "https://example.com?_sp=\(userId).\(epoch).\(sessionId).\(subjectUserId).\(appId).\(platform)"
),
(
config: CrossDeviceParameterConfiguration(subjectUserId: true, sourcePlatform: true, reason: reason),
expected: "https://example.com?_sp=\(userId).\(epoch).\(sessionId).\(subjectUserId).\(appId).\(platform).\(reasonb64)"
),
(
config: CrossDeviceParameterConfiguration(sessionId: false, sourceId: false, reason: reason),
expected: "https://example.com?_sp=\(userId).\(epoch).....\(reasonb64)"
)
]

for (config, expected) in testCases {
matches(
for: expected,
in: tracker.decorateLink(link, extendedParameters: config)!.absoluteString
)
}
// All false
matches(
for: "https://example.com?_sp=\(userId).\(epoch)",
in: tracker.decorateLink(link, extendedParameters: CrossDeviceParameterConfiguration(sessionId: false, sourceId: false))!.absoluteString
)

// Default
matches(
for: "https://example.com?_sp=\(userId).\(epoch).\(sessionId)..\(appId)",
in: tracker.decorateLink(link, extendedParameters: CrossDeviceParameterConfiguration())!.absoluteString
)

matches(
for: "https://example.com?_sp=\(userId).\(epoch).\(sessionId).\(subjectUserId).\(appId)",
in: tracker.decorateLink(link, extendedParameters: CrossDeviceParameterConfiguration(subjectUserId: true))!.absoluteString
)

matches(
for: "https://example.com?_sp=\(userId).\(epoch).\(sessionId).\(subjectUserId).\(appId).\(platform)",
in: tracker.decorateLink(link, extendedParameters: CrossDeviceParameterConfiguration(subjectUserId: true, sourcePlatform: true))!.absoluteString
)

matches(
for: "https://example.com?_sp=\(userId).\(epoch).\(sessionId).\(subjectUserId).\(appId).\(platform).\(reasonb64)",
in: tracker.decorateLink(link, extendedParameters: CrossDeviceParameterConfiguration(subjectUserId: true, sourcePlatform: true, reason: reason))!.absoluteString
)

matches(
for: "https://example.com?_sp=\(userId).\(epoch).....\(reasonb64)",
in: tracker.decorateLink(link, extendedParameters: CrossDeviceParameterConfiguration(sessionId: false, sourceId: false, reason: reason))!.absoluteString
)
}

func testWithExistingSpQueryParameter() {
Expand Down

0 comments on commit e80ec11

Please sign in to comment.