From e80ec11fb7ecdd906ed0ced56c941c9d071d3355 Mon Sep 17 00:00:00 2001 From: Greg Leonard <45019882+greg-el@users.noreply.github.com> Date: Thu, 28 Sep 2023 09:19:33 +0100 Subject: [PATCH] Remove loop from test --- Tests/TestLinkDecorator.swift | 67 ++++++++++++++++------------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/Tests/TestLinkDecorator.swift b/Tests/TestLinkDecorator.swift index cba77bb28..ef0de418f 100644 --- a/Tests/TestLinkDecorator.swift +++ b/Tests/TestLinkDecorator.swift @@ -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() {