openclaw/apps/ios/Tests/NotificationServingPreferenceTests.swift
Peter Steinberger 6621ead871
improve(ios): manage notifications from Privacy (#102733)
* improve(ios): manage notifications from privacy

Co-authored-by: Sahil Satralkar <62758655+sahilsatralkar@users.noreply.github.com>

* fix(ios): make notification status returns explicit

---------

Co-authored-by: Sahil Satralkar <62758655+sahilsatralkar@users.noreply.github.com>
2026-07-09 12:35:29 +01:00

29 lines
1.1 KiB
Swift

import Foundation
import Testing
@testable import OpenClaw
struct NotificationServingPreferenceTests {
@Test func `defaults to enabled`() throws {
let (suiteName, defaults) = try self.makeDefaults()
defer { defaults.removePersistentDomain(forName: suiteName) }
#expect(NotificationServingPreference.isEnabled(defaults: defaults))
}
@Test func `persists explicit opt out and opt in`() throws {
let (suiteName, defaults) = try self.makeDefaults()
defer { defaults.removePersistentDomain(forName: suiteName) }
defaults.set(false, forKey: NotificationServingPreference.storageKey)
#expect(!NotificationServingPreference.isEnabled(defaults: defaults))
defaults.set(true, forKey: NotificationServingPreference.storageKey)
#expect(NotificationServingPreference.isEnabled(defaults: defaults))
}
private func makeDefaults() throws -> (String, UserDefaults) {
let suiteName = "NotificationServingPreferenceTests.\(UUID().uuidString)"
let defaults = try #require(UserDefaults(suiteName: suiteName))
return (suiteName, defaults)
}
}