Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify in-app event listener action parameters to new name #255

Merged
merged 23 commits into from Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/MessagingInApp/MessagingInAppImplementation.swift
Expand Up @@ -110,8 +110,8 @@ extension MessagingInAppImplementation: GistDelegate {

eventListener?.messageActionTaken(
message: InAppMessage(gistMessage: message),
action: action,
name: name
actionValue: action,
actionName: name
)
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/MessagingInApp/Type/InAppEventListener.swift
Expand Up @@ -6,5 +6,5 @@ public protocol InAppEventListener: AutoMockable {
func messageShown(message: InAppMessage)
func messageDismissed(message: InAppMessage)
func errorWithMessage(message: InAppMessage)
func messageActionTaken(message: InAppMessage, action: String, name: String)
func messageActionTaken(message: InAppMessage, actionValue: String, actionName: String)
}
Expand Up @@ -211,21 +211,21 @@ public class InAppEventListenerMock: InAppEventListener, Mock {
}

/// The arguments from the *last* time the function was called.
public private(set) var messageActionTakenReceivedArguments: (message: InAppMessage, action: String, name: String)?
public private(set) var messageActionTakenReceivedArguments: (message: InAppMessage, actionValue: String, actionName: String)?
/// Arguments from *all* of the times that the function was called.
public private(set) var messageActionTakenReceivedInvocations: [(message: InAppMessage, action: String, name: String)] = []
public private(set) var messageActionTakenReceivedInvocations: [(message: InAppMessage, actionValue: String, actionName: String)] = []
/**
Set closure to get called when function gets called. Great way to test logic or return a value for the function.
*/
public var messageActionTakenClosure: ((InAppMessage, String, String) -> Void)?

/// Mocked function for `messageActionTaken(message: InAppMessage, action: String, name: String)`. Your opportunity to return a mocked value and check result of mock in test code.
public func messageActionTaken(message: InAppMessage, action: String, name: String) {
/// Mocked function for `messageActionTaken(message: InAppMessage, actionValue: String, actionName: String)`. Your opportunity to return a mocked value and check result of mock in test code.
public func messageActionTaken(message: InAppMessage, actionValue: String, actionName: String) {
mockCalled = true
messageActionTakenCallsCount += 1
messageActionTakenReceivedArguments = (message: message, action: action, name: name)
messageActionTakenReceivedInvocations.append((message: message, action: action, name: name))
messageActionTakenClosure?(message, action, name)
messageActionTakenReceivedArguments = (message: message, actionValue: actionValue, actionName: actionName)
messageActionTakenReceivedInvocations.append((message: message, actionValue: actionValue, actionName: actionName))
messageActionTakenClosure?(message, actionValue, actionName)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Tests/MessagingInApp/APITest.swift
Expand Up @@ -41,5 +41,5 @@ extension MessagingInAppAPITest: InAppEventListener {

func errorWithMessage(message: InAppMessage) {}

func messageActionTaken(message: InAppMessage, action: String, name: String) {}
func messageActionTaken(message: InAppMessage, actionValue: String, actionName: String) {}
}
4 changes: 2 additions & 2 deletions Tests/MessagingInApp/MessagingInAppImplementationTest.swift
Expand Up @@ -132,8 +132,8 @@ class MessagingInAppImplementationTest: UnitTest {
)
XCTAssertEqual(eventListenerMock.messageActionTakenCallsCount, 1)
XCTAssertEqual(eventListenerMock.messageActionTakenReceivedArguments?.message, expectedInAppMessage)
XCTAssertEqual(eventListenerMock.messageActionTakenReceivedArguments?.action, givenAction)
XCTAssertEqual(eventListenerMock.messageActionTakenReceivedArguments?.name, givenName)
XCTAssertEqual(eventListenerMock.messageActionTakenReceivedArguments?.actionValue, givenAction)
XCTAssertEqual(eventListenerMock.messageActionTakenReceivedArguments?.actionName, givenName)
}

func test_eventListeners_expectCallListenerForEachEvent() {
Expand Down