PuzzleNotificationTextTests.swift (1536B)
1 import Foundation 2 import Testing 3 4 @testable import Crossmate 5 6 @Suite("Puzzle notification text") 7 struct PuzzleNotificationTextTests { 8 @Test("Puzzle title includes subtitle separated by an en dash") 9 func titleIncludesSubtitle() { 10 let date = Calendar(identifier: .gregorian).date(from: DateComponents(year: 2001, month: 1, day: 1)) 11 12 let title = PuzzleNotificationText.title("Saturday Puzzle", publisher: nil, date: date) 13 14 #expect(title.contains("Saturday Puzzle – ")) 15 #expect(title.contains("2001")) 16 } 17 18 @Test("Notification body quotes puzzle title") 19 func bodyQuotesPuzzleTitle() { 20 let ping = Ping( 21 recordName: "ping-test-1", 22 gameID: UUID(), 23 authorID: "alice", 24 playerName: "Alice", 25 puzzleTitle: "Saturday Puzzle – 1 January 2001", 26 kind: .join, 27 scope: nil 28 ) 29 30 #expect(AppServices.bodyText(for: ping) == "Alice joined the puzzle 'Saturday Puzzle – 1 January 2001'") 31 } 32 33 @Test("Puzzle check says all of the puzzle") 34 func puzzleCheckSaysAllOfPuzzle() { 35 let ping = Ping( 36 recordName: "ping-test-2", 37 gameID: UUID(), 38 authorID: "alice", 39 playerName: "Alice", 40 puzzleTitle: "Saturday Puzzle – 1 January 2001", 41 kind: .check, 42 scope: .puzzle 43 ) 44 45 #expect(AppServices.bodyText(for: ping) == "Alice checked all of the puzzle 'Saturday Puzzle – 1 January 2001'") 46 } 47 }