damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

DamusPurpleImpendingExpirationTests.swift (2246B)


      1 //
      2 //  DamusPurpleImpendingExpirationTests.swift
      3 //  damusTests
      4 //
      5 //  Created by Daniel D’Aquino on 2024-02-26.
      6 //
      7 
      8 import XCTest
      9 @testable import damus
     10 
     11 final class DamusPurpleImpendingExpirationTests : XCTestCase {
     12     func testNotificationContentSetDoesNotAllowRepetition() {
     13         var notification_contents: Set<DamusAppNotification.Content> = []
     14         let expiry_date = UInt64(Date.now.timeIntervalSince1970)
     15         let now = Date.now
     16         let notification_1 = DamusAppNotification(content: .purple_impending_expiration(days_remaining: 3, expiry_date: expiry_date), timestamp: now)
     17         notification_contents.insert(notification_1.content)
     18         let notification_2 = DamusAppNotification(content: .purple_impending_expiration(days_remaining: 3, expiry_date: expiry_date), timestamp: now)
     19         notification_contents.insert(notification_2.content)
     20         let notification_3 = DamusAppNotification(content: .purple_impending_expiration(days_remaining: 2, expiry_date: expiry_date), timestamp: now)
     21         notification_contents.insert(notification_3.content)
     22         let notification_4 = DamusAppNotification(content: .purple_impending_expiration(days_remaining: 2, expiry_date: expiry_date), timestamp: now)
     23         notification_contents.insert(notification_4.content)
     24         let notification_5 = DamusAppNotification(content: .purple_impending_expiration(days_remaining: 1, expiry_date: expiry_date), timestamp: now)
     25         notification_contents.insert(notification_5.content)
     26         let notification_6 = DamusAppNotification(content: .purple_impending_expiration(days_remaining: 1, expiry_date: expiry_date), timestamp: now)
     27         notification_contents.insert(notification_6.content)
     28         XCTAssertEqual(notification_contents.count, 3)
     29         XCTAssertTrue(notification_contents.contains(notification_1.content))
     30         XCTAssertTrue(notification_contents.contains(notification_2.content))
     31         XCTAssertTrue(notification_contents.contains(notification_3.content))
     32         XCTAssertTrue(notification_contents.contains(notification_4.content))
     33         XCTAssertTrue(notification_contents.contains(notification_5.content))
     34         XCTAssertTrue(notification_contents.contains(notification_6.content))
     35     }
     36 }
     37