Testing inside the Angular-UI Bootstrap dialog promise
I'm using the Angular-UI Bootstrap dialogs and loving them, but I seem to
be having trouble figuring out how to test what comes back from them when
they are closed (or anything else inside the promise for that matter.) Can
somebody point me to an example of how this is tested? I suspect that I am
just not mocking it correctly. Here's what I have for tests:
spyOn(scope.orderDetailsModal, 'open').andReturn({then:function(){return
"fulfill";}});
scope.orderDetailsModal.isOpen = function(){return true;};
scope.orderDetails();
expect(scope.orderDetailsModal.open).not.toHaveBeenCalled();
scope.orderDetailsModal.isOpen = function(){return false;};
scope.orderDetails();
scope.$digest();
expect(scope.orderDetailsModal.open).toHaveBeenCalled();
expect(scope.testresult).toEqual("fulfill");
Of course, the test for scope.testresult fails. Needless to say, I'm
feeling a bit lost.
No comments:
Post a Comment