From 23edd96131d95e5e18b50dcbe568370cb0b5c30b Mon Sep 17 00:00:00 2001 From: Dominik Kapusta Date: Tue, 12 Dec 2023 09:21:51 +0100 Subject: [PATCH] Revert "Revert "Revert "Disable failing test""" This reverts commit a603a5ffb46a794f8aaabc82947f089ddea06312. --- .../Tests/PixelKitTests/PixelKitTests.swift | 88 +++++++++---------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/LocalPackages/PixelKit/Tests/PixelKitTests/PixelKitTests.swift b/LocalPackages/PixelKit/Tests/PixelKitTests/PixelKitTests.swift index c7001de2c0..d3995fd822 100644 --- a/LocalPackages/PixelKit/Tests/PixelKitTests/PixelKitTests.swift +++ b/LocalPackages/PixelKit/Tests/PixelKitTests/PixelKitTests.swift @@ -229,50 +229,50 @@ final class PixelKitTests: XCTestCase { } /// Test firing a daily pixel a few times -// func testDailyPixelFrequency() { -// // Prepare test parameters -// let appVersion = "1.0.5" -// let headers = ["a": "2", "b": "3", "c": "2000"] -// let log = OSLog(subsystem: "TestSubsystem", category: "TestCategory") -// let event = TestEvent.dailyEvent -// let userDefaults = userDefaults() -// -// let timeMachine = TimeMachine() -// -// // Set expectations -// let fireCallbackCalled = expectation(description: "Expect the pixel firing callback to be called") -// fireCallbackCalled.expectedFulfillmentCount = 3 -// fireCallbackCalled.assertForOverFulfill = true -// -// // Prepare mock to validate expectations -// let pixelKit = PixelKit(dryRun: false, -// appVersion: appVersion, -// defaultHeaders: headers, -// log: log, -// dailyPixelCalendar: nil, -// dateGenerator: timeMachine.now, -// defaults: userDefaults) { _, _, _, _, _, _ in -// fireCallbackCalled.fulfill() -// } -// -// // Run test -// pixelKit.fire(event, frequency: .dailyOnly) // Fired -// -// timeMachine.travel(by: 60 * 60 * 2) -// pixelKit.fire(event, frequency: .dailyOnly) // Skipped (2 hours since last fire) -// -// timeMachine.travel(by: 60 * 60 * 24 + 1000) -// pixelKit.fire(event, frequency: .dailyOnly) // Fired (24 hours + 1000 seconds since last fire) -// -// timeMachine.travel(by: 60 * 60 * 10) -// pixelKit.fire(event, frequency: .dailyOnly) // Skipped (10 hours since last fire) -// -// timeMachine.travel(by: 60 * 60 * 14) -// pixelKit.fire(event, frequency: .dailyOnly) // Fired (24 hours since last fire) -// -// // Wait for expectations to be fulfilled -// wait(for: [fireCallbackCalled], timeout: 0.5) -// } + func testDailyPixelFrequency() { + // Prepare test parameters + let appVersion = "1.0.5" + let headers = ["a": "2", "b": "3", "c": "2000"] + let log = OSLog(subsystem: "TestSubsystem", category: "TestCategory") + let event = TestEvent.dailyEvent + let userDefaults = userDefaults() + + let timeMachine = TimeMachine() + + // Set expectations + let fireCallbackCalled = expectation(description: "Expect the pixel firing callback to be called") + fireCallbackCalled.expectedFulfillmentCount = 3 + fireCallbackCalled.assertForOverFulfill = true + + // Prepare mock to validate expectations + let pixelKit = PixelKit(dryRun: false, + appVersion: appVersion, + defaultHeaders: headers, + log: log, + dailyPixelCalendar: nil, + dateGenerator: timeMachine.now, + defaults: userDefaults) { _, _, _, _, _, _ in + fireCallbackCalled.fulfill() + } + + // Run test + pixelKit.fire(event, frequency: .dailyOnly) // Fired + + timeMachine.travel(by: 60 * 60 * 2) + pixelKit.fire(event, frequency: .dailyOnly) // Skipped (2 hours since last fire) + + timeMachine.travel(by: 60 * 60 * 24 + 1000) + pixelKit.fire(event, frequency: .dailyOnly) // Fired (24 hours + 1000 seconds since last fire) + + timeMachine.travel(by: 60 * 60 * 10) + pixelKit.fire(event, frequency: .dailyOnly) // Skipped (10 hours since last fire) + + timeMachine.travel(by: 60 * 60 * 14) + pixelKit.fire(event, frequency: .dailyOnly) // Fired (24 hours since last fire) + + // Wait for expectations to be fulfilled + wait(for: [fireCallbackCalled], timeout: 0.5) + } /// Test firing a unique pixel func testUniquePixel() {