-
Notifications
You must be signed in to change notification settings - Fork 354
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change account expiry text to display 'less than a day'
- Loading branch information
Jon Petersson
committed
Nov 7, 2023
1 parent
7e9bb04
commit 70f72cd
Showing
5 changed files
with
114 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// | ||
// AccountExpiryTests.swift | ||
// MullvadVPNTests | ||
// | ||
// Created by Jon Petersson on 2023-11-07. | ||
// Copyright © 2023 Mullvad VPN AB. All rights reserved. | ||
// | ||
|
||
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) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters