mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Add toggle not invite notifications. (#2207)
This commit is contained in:
@@ -388,4 +388,84 @@ class NotificationSettingsScreenViewModelTests: XCTestCase {
|
||||
|
||||
XCTAssertNotNil(context.alertInfo)
|
||||
}
|
||||
|
||||
func testToggleInvitationsOff() async throws {
|
||||
notificationSettingsProxy.isInviteForMeEnabledReturnValue = true
|
||||
|
||||
let deferredInitialFetch = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.settings != nil
|
||||
}
|
||||
|
||||
viewModel.fetchInitialContent()
|
||||
|
||||
try await deferredInitialFetch.fulfill()
|
||||
|
||||
context.invitationsEnabled = false
|
||||
let deferred = deferFulfillment(notificationSettingsProxy.callbacks) { callback in
|
||||
callback == .settingsDidChange
|
||||
}
|
||||
|
||||
context.send(viewAction: .invitationsChanged)
|
||||
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssert(notificationSettingsProxy.setInviteForMeEnabledEnabledCalled)
|
||||
XCTAssertEqual(notificationSettingsProxy.setInviteForMeEnabledEnabledReceivedEnabled, false)
|
||||
}
|
||||
|
||||
func testToggleInvitationsOn() async throws {
|
||||
notificationSettingsProxy.isInviteForMeEnabledReturnValue = false
|
||||
|
||||
let deferredInitialFetch = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.settings != nil
|
||||
}
|
||||
|
||||
viewModel.fetchInitialContent()
|
||||
|
||||
try await deferredInitialFetch.fulfill()
|
||||
|
||||
context.invitationsEnabled = true
|
||||
|
||||
let deferred = deferFulfillment(notificationSettingsProxy.callbacks) { callback in
|
||||
callback == .settingsDidChange
|
||||
}
|
||||
|
||||
context.send(viewAction: .invitationsChanged)
|
||||
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssert(notificationSettingsProxy.setInviteForMeEnabledEnabledCalled)
|
||||
XCTAssertEqual(notificationSettingsProxy.setInviteForMeEnabledEnabledReceivedEnabled, true)
|
||||
}
|
||||
|
||||
func testToggleInvitesFailure() async throws {
|
||||
notificationSettingsProxy.setInviteForMeEnabledEnabledThrowableError = NotificationSettingsError.Generic(msg: "error")
|
||||
notificationSettingsProxy.isInviteForMeEnabledReturnValue = false
|
||||
|
||||
let deferredInitialFetch = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
state.settings != nil
|
||||
}
|
||||
|
||||
viewModel.fetchInitialContent()
|
||||
|
||||
try await deferredInitialFetch.fulfill()
|
||||
|
||||
context.invitationsEnabled = true
|
||||
|
||||
var deferred = deferFulfillment(context.$viewState) { state in
|
||||
state.applyingChange == true
|
||||
}
|
||||
|
||||
context.send(viewAction: .invitationsChanged)
|
||||
|
||||
try await deferred.fulfill()
|
||||
|
||||
deferred = deferFulfillment(context.$viewState) { state in
|
||||
state.applyingChange == false
|
||||
}
|
||||
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssertNotNil(context.alertInfo)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3d858bdd5b55a445ce924c4bba25a8ca420086c033ca5e17b4a73cf571d90c15
|
||||
size 97653
|
||||
oid sha256:6ca120ad1ccae3415ebf22f9db7fc8389e2b21682ae336de2545651c2027cc87
|
||||
size 155222
|
||||
|
||||
+2
-2
@@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:3d858bdd5b55a445ce924c4bba25a8ca420086c033ca5e17b4a73cf571d90c15
|
||||
size 97653
|
||||
oid sha256:321892e72a5da150eb1a2db3b81576eac4a9474aec8cee5c68c8c3315b3dbe46
|
||||
size 126720
|
||||
|
||||
Reference in New Issue
Block a user