You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/WebPushTesting/WebPushManager+Testing.swift
+46-7
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,21 @@
8
8
9
9
import Logging
10
10
import WebPush
11
+
import Synchronization
11
12
12
13
extensionWebPushManager{
13
14
/// A push message in its original form, either ``/Foundation/Data``, ``/Swift/String``, or ``/Foundation/Encodable``.
14
15
/// - Warning: Never switch on the message type, as values may be added to it over time.
15
16
publictypealiasMessage=_Message
16
17
18
+
publictypealiasMessageHandler=@Sendable(
19
+
_ message:Message,
20
+
_ subscriber:Subscriber,
21
+
_ topic:Topic?,
22
+
_ expiration:Expiration,
23
+
_ urgency:Urgency
24
+
)asyncthrows->Void
25
+
17
26
/// Create a mocked web push manager.
18
27
///
19
28
/// The mocked manager will forward all messages as is to its message handler so that you may either verify that a push was sent, or inspect the contents of the message that was sent.
/// The mocked manager will forward all messages as is to its message handlers so that you may either verify that a push was sent, or inspect the contents of the message that was sent. Assign multiple handlers here to have each message that comes in rotate through the handlers, looping when they are exausted.
53
+
///
54
+
/// - Parameters:
55
+
/// - vapidConfiguration: A VAPID configuration, though the mocked manager doesn't make use of it.
56
+
/// - logger: An optional logger.
57
+
/// - messageHandlers: A list of handlers to receive messages or throw errors.
58
+
/// - Returns: A new manager suitable for mocking.
0 commit comments