jubianchi/atoum.js

Allow to reset a callback controller

Opened this issue · 2 comments

I can't write this code:

        this
            .given(o = new MyObject())
            .and(o.setSomething(myCallback = this.generateCallback()))

            .if(o.doSomething())
                .callback(myCallback)
                    .wasCalled()

            .if(o.doOtherThing())
                .callback(myCallback)
                    .wasNotCalled()

Because, in the second test, the callback was already called in first test.

So, we need a way to reset the callback controller.

@marmotz you are totally right!

What about somethign like that:

var o, myCallback;

this
    .given(o = new MyObject())
    .and(o.setSomething(myCallback = this.generateCallback()))

    .if(o.doSomething())
        .callback(myCallback) .wasCalled()

    .resetCallback(myCallback)

    //...
;

I'll also add the same method for mocks and stubs (resetMock and resetStub)

it seems great !