angularjsrxjsjasminejasmine2.0

Mock rxjs debounce in Jasmine 2


I have the following observable function:

$scope.$createObservableFunction("getInformation")
                    .debounce(300)
                    .flatMapLatest(function() {
                        return lookupService.getInformation($scope.basicDetails);
                    })
                    .subscribe(function(info) {
                        $scope.info = info;
                    });

I am testing this by running $scope.getInformation(); in each test. I then want to check that the service has been called

it("should call the function retrieving the ABN details and new ABN details assigned", function () {
            expect(lookupService.getInformation).toHaveBeenCalledWith($scope.identity.basicInformation);
        });

This originally worked, but I have now added the debounce method. How can I mock this method using Jasmine 2.0.0? I don't want to use a settimeout/timer based approach


Solution

  • Not really an answer, but I ended up using the timer based approach.