diff options
| author | ivar <i@oiee.no> | 2026-03-23 16:37:31 +0100 |
|---|---|---|
| committer | ivar <i@oiee.no> | 2026-03-23 16:37:31 +0100 |
| commit | 116c373099af46a11ac4320aac21f58f3549c027 (patch) | |
| tree | f336f0905c2ed09280c0edd0c701e2e8db645e72 /SolverVTests | |
| parent | f72e25fef049c91041335819332e35dba2efb0d2 (diff) | |
| download | solverv-116c373099af46a11ac4320aac21f58f3549c027.tar.xz solverv-116c373099af46a11ac4320aac21f58f3549c027.zip | |
feat: add AppGroupManager for widget-app data syncing
Diffstat (limited to 'SolverVTests')
| -rw-r--r-- | SolverVTests/Utilities/AppGroupManagerTests.swift | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/SolverVTests/Utilities/AppGroupManagerTests.swift b/SolverVTests/Utilities/AppGroupManagerTests.swift new file mode 100644 index 0000000..9b5e587 --- /dev/null +++ b/SolverVTests/Utilities/AppGroupManagerTests.swift @@ -0,0 +1,58 @@ +import XCTest +@testable import Solverv + +final class AppGroupManagerTests: XCTestCase { + var manager: AppGroupManager! + + override func setUp() { + super.setUp() + manager = AppGroupManager() + manager.clearAllData() + } + + override func tearDown() { + super.tearDown() + manager.clearAllData() + } + + func testSaveAndRetrieveLocation() { + let location = AppGroupManager.UserLocation( + latitude: 59.9139, + longitude: 10.7522, + timestamp: "2026-03-23T10:00:00Z", + isDefaultLocation: false + ) + + manager.saveLocation(location) + let retrieved = manager.getLocation() + + XCTAssertNotNil(retrieved) + XCTAssertEqual(retrieved?.latitude, 59.9139) + XCTAssertEqual(retrieved?.longitude, 10.7522) + } + + func testSaveAndRetrieveSunTimes() { + let sunTimes = AppGroupManager.SunTimes( + date: "2026-03-20", + sunrise: "2026-03-20T06:42:00", + sunset: "2026-03-20T18:15:00", + timestamp: "2026-03-23T10:00:00Z" + ) + + manager.saveSunTimes(sunTimes) + let retrieved = manager.getSunTimes() + + XCTAssertNotNil(retrieved) + XCTAssertEqual(retrieved?.date, "2026-03-20") + } + + func testClearData() { + let location = AppGroupManager.UserLocation( + latitude: 0.0, longitude: 0.0, timestamp: "2026-03-23T10:00:00Z", isDefaultLocation: true + ) + manager.saveLocation(location) + manager.clearAllData() + + XCTAssertNil(manager.getLocation()) + } +} |
