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

Why the reset function doesn't reset the mock configuration? #10

Closed
michalstocki opened this issue Feb 1, 2017 · 1 comment
Closed

Comments

@michalstocki
Copy link
Contributor

michalstocki commented Feb 1, 2017

When I can see the reset function, I expect them to reset not only the calls which were recorded, but also the mocked functionality of all the methods.

I expect the following test to pass:

describe('Mock resetting', () => {
    it('should reset a value configured to be returned', () => {
        // given
        const myClassMock = mock(MyClass);
        when(myClassMock.methodB('some string')).thenReturn('other string');
        const myClass = instance(myClassMock);
        reset(myClassMock);

        // when
        const result = myClass.methodB('some string');

        // then
        expect(result).to.not.equal('other string');
    });
});

class MyClass {

    public methodB(someArgument:string):string {
        return `provided value: ${someArgument}`;
    }
}

Here is a link for the test within the configured project:
https://github.com/michalstocki/ts-mockito-example/blob/master/test/spec/extension/resetting/mock-resetting.spec.ts

@michalstocki michalstocki changed the title Why the reset function doesn't reset the mock configuration Why the reset function doesn't reset the mock configuration? Feb 1, 2017
michalstocki added a commit to michalstocki/ts-mockito-example that referenced this issue Feb 1, 2017
@NagRock
Copy link
Owner

NagRock commented Feb 3, 2017

@NagRock NagRock closed this as completed Feb 3, 2017
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

2 participants