cleishm / jsmockito

Javascript mocking framework inspired by the awesome mockito
http://jsmockito.org
Other
106 stars 19 forks source link

Can I do iterator-style stubbing with jsMockito? #24

Open noppanit opened 11 years ago

noppanit commented 11 years ago

Hi,

I have just come across your library. And I have just a quick question to ask.

Can I do consecutive stubbing callback with JsMockito?

I have this code that I would like to test. It's a recursive call until the count is equal to 5. I have been scouting all over the Internet until I come across your library and I'm a big fan of Mockito.

    var callback = function(result) {
        if(result.count < 5) {
            msg_id = result.msg_id;
            MovieService.getMovies(msg_id, result.count).get(callback, error);
        }

        if(result.movies.length !== 0) {
            setDataToDisplay(result);
        }

        if(result.count === 5) {
            $scope.loading = false;
        }
    }

    MovieService.getMovies(msg_id, 0).get(callback, error);
cleishm commented 11 years ago

I'm unsure what it is you're trying to stub? Have you written a sample test yet?