-
Notifications
You must be signed in to change notification settings - Fork 392
/
Copy pathAccountExpiryTests.swift
49 lines (41 loc) · 1.45 KB
/
AccountExpiryTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// AccountExpiryTests.swift
// MullvadVPNTests
//
// Created by Jon Petersson on 2023-11-07.
// Copyright © 2023 Mullvad VPN AB. All rights reserved.
//
@testable import MullvadVPN
import XCTest
class AccountExpiryTests: XCTestCase {
func testNoDateReturnsNoDuration() {
let accountExpiry = AccountExpiry()
XCTAssertNil(accountExpiry.formattedDuration)
}
func testDateNowReturnsNoDuration() {
let accountExpiry = AccountExpiry(expiryDate: Date())
XCTAssertNil(accountExpiry.formattedDuration)
}
func testDateInPastReturnsNoDuration() {
let accountExpiry = AccountExpiry(expiryDate: Date().addingTimeInterval(-10))
XCTAssertNil(accountExpiry.formattedDuration)
}
func testDateWithinTriggerIntervalReturnsDuration() {
let date = Calendar.current.date(
byAdding: .day,
value: NotificationConfiguration.closeToExpiryTriggerInterval - 1,
to: Date()
)
let accountExpiry = AccountExpiry(expiryDate: date)
XCTAssertNotNil(accountExpiry.formattedDuration)
}
func testDateNotWithinTriggerIntervalReturnsNoDuration() {
let date = Calendar.current.date(
byAdding: .day,
value: NotificationConfiguration.closeToExpiryTriggerInterval + 1,
to: Date()
)
let accountExpiry = AccountExpiry(expiryDate: date)
XCTAssertNil(accountExpiry.formattedDuration)
}
}