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

Mocked return value is different for different cases #358

Open
shurale85 opened this issue Feb 20, 2024 · 0 comments
Open

Mocked return value is different for different cases #358

shurale85 opened this issue Feb 20, 2024 · 0 comments

Comments

@shurale85
Copy link

Hi!
Not really sure if this is an issue. I guess I miss smth internal of swiftymoky.
I have protocol:

// this is from object
public protocol MailAddressProtocol: AutoMockable {
    var mailbox: String? { get }
    var displayName: String? { get }
}

public extension MailAddressProtocol {
    var title: String? {
        guard let displayName = self.displayName else {
            return mailbox
        }
        
        return displayName
    }
}
  • I set property title of mock object from, so it returns string "test title"
  • I set property fromof mock object header, so it returns object from
  • And I expect that from.title equals to header.from!.title.
let from = MailAddressProtocolMock()
from.given(.title(getter: "Test title"))
header.given(.from(getter: from))
var t = from.title // test title
var h = header.from!.title // nil

However, my expectation is failed. from.title returns "test title" and header.from!.title returns nil

When I call from.title it returns given value and when I call header.from!.title it returns value from title of extension MailAddressProtocol.
I can't understand why does the same object from have different behavior.

telegram-cloud-photo-size-2-5377773627459623126-x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant