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

Allow behavior to be set for a stubbed method #19

Open
matthewmcnew opened this issue Apr 10, 2017 · 1 comment
Open

Allow behavior to be set for a stubbed method #19

matthewmcnew opened this issue Apr 10, 2017 · 1 comment

Comments

@matthewmcnew
Copy link
Owner

It would be cool if we could do something like this:

import SafeMock, {Mock} from "safe-mock";

interface SomeService {
    createSomething(argument: number): string;
}

const mock: Mock<SomeService> = SafeMock.build<SomeService>();

when(mock.createSomething).thenCall((argument) => {
      return argument + "aha!";
}) 
@matthewmcnew
Copy link
Owner Author

matthewmcnew commented Apr 10, 2017

This should not compile:

import SafeMock, {Mock} from "safe-mock";

interface SomeService {
    createSomething(argument: number): string;
}

const mock: Mock<SomeService> = SafeMock.build<SomeService>();

when(mock.createSomething).thenCall((argument) => {
      return 22;
}) 

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