NotificationStateTests.swift (1016B)
1 import Foundation 2 import Testing 3 4 @testable import Crossmate 5 6 @Suite("Notification state", .serialized) 7 struct NotificationStateTests { 8 @Test("Active puzzle suppresses only until it is cleared") 9 func activePuzzleSuppressionClears() { 10 let gameID = UUID() 11 NotificationState.setActivePuzzleID(nil) 12 13 NotificationState.setActivePuzzleID(gameID) 14 #expect(NotificationState.isActive(gameID: gameID)) 15 16 NotificationState.clearActivePuzzleID(if: gameID) 17 #expect(!NotificationState.isActive(gameID: gameID)) 18 } 19 20 @Test("Clearing one puzzle does not clear another active puzzle") 21 func clearActivePuzzleRequiresMatchingID() { 22 let gameID = UUID() 23 let otherID = UUID() 24 NotificationState.setActivePuzzleID(nil) 25 26 NotificationState.setActivePuzzleID(gameID) 27 NotificationState.clearActivePuzzleID(if: otherID) 28 29 #expect(NotificationState.activePuzzleID() == gameID) 30 NotificationState.setActivePuzzleID(nil) 31 } 32 }